2👍
✅
This is one query, is it the mapping you wanted?
output = collections.defaultdict(list)
values = RecipientListEmail.objects.values_list('recipient_list__pk', 'email')
for recipient_id, email in values:
output[recipient_id].append(email)
👤wim
Source:stackexchange.com