2👍
✅
How about fetching both objects in the same query? That way you know you have two distinct entries.
a, c = Entry.objects.filter(first_name__contains='Br')).order_by('?')[0:2]
b = a.id
d = c.id
Note that this will raise a ValueError
if the filter matches fewer than two entries.
Source:stackexchange.com