问题
I have a very simple query: select * from tbl1 where title not in('asdasd', 'asdasd')
.
How do I translate that to Django? It's like I want the opposite of: Table.objects.filter(title__in=myListOfTitles)
回答1:
try using exclude
Table.objects.exclude(title__in=myListOfTitles)
回答2:
Table.objects.exclude(title__in=myListOfTitles)
来源:https://stackoverflow.com/questions/9003518/django-equivalent-of-sql-not-in