1👍
✅
You can work with:
Record.objects.filter(batch=None)
yes, I was amazed by that as well when I found out.
This works because Django for each relation makes a LEFT OUTER JOIN
, so if there is no batch
, it will join with a NULL
/None
record and so we can filter on that one.
Source:stackexchange.com