Django equivalent of SQL not in

Ali picture Ali · Jan 25, 2012 · Viewed 43.5k times · Source

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)

Answer

JamesO picture JamesO · Jan 25, 2012

try using exclude

Table.objects.exclude(title__in=myListOfTitles)