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)
Django and SQL are not replacements for one another, Django is a web framework as a whole, designed to develop web applications, and SQL is a language to query databases.
Django's exclude () method basically returns a new QuerySet containing the objects that do not match the given parameter.
Django creates a file with any new changes and stores the file in the /migrations/ folder. Next time you run py manage.py migrate Django will create and execute an SQL statement, based on the content of the new file in the migrations folder.
try using exclude
Table.objects.exclude(title__in=myListOfTitles)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With