I’m trying to figure out how to write a ‘not in’ style query in django.
For example, the query structure I’m thinking of would look like this.
select table1.*
from table1
where table1.id not in
(
select table2.key_to_table1
from table2
where table2.id = some_parm
)
What would the django syntax look like assuming models called table1 and table2?
The exclude function works like the
Notoperator you where asking for. The attributeflat = Truetells totable2query to return thevalue_listas a one level list. So… at the end you are obtaining a list ofIDsfrom table2, which you are going to user to define the condition intable1, that will be denied by the exclude function.