How this SQL query can be translated to Django ORM statement?
SELECT field1, field2, field3
FROM table1
WHERE field1 NOT IN
(SELECT 2_field1 FROM table2);
Kindly help! :)
pstable1
and table2
not bounded with ForeignKey
or ManyToMany
Using two QuerySets, as shown in the docs.
inner_qs = table2.objects.all()
results = table1.objects.exclude(field1__in=inner_qs)
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