3👍
✅
Renaming l
for readability:
names = ['Bob','Dave','Jane']
Person.objects.[exclude][1](Name__[in][2]=names)
UPDATE 1: Answer to the second question (in your ‘EDIT’ paragraph):
present = Person.objects.values_list('Name', flat=True)
absent = set(names) - set(present)
# or, if you prefer named functions to the set operator '-'
absent = set(names).difference(present)
Yes, the “right hand side” of difference (but not ‘-‘) accepts any iterable (I had to look it up to confirm).
👤msw
- [Django]-Custom logo in django jet
- [Django]-Django admin list_display with count annotation
- [Django]-Model datetime field validation for fields with auto_now
- [Django]-Django rest framework & external api
Source:stackexchange.com