1👍
✅
You can .filter(…)
[Django-doc] with:
Entity.objects.filter(apple=None, orange=None, banana=None)
This will make LEFT OUTER JOIN
s on the tables for the Apple
, Orange
, and Banana
models, and then check if these are None
/NULL
.
It will work with the value related_query_name=…
parameter [Django-doc] for the ForeignKey
s from Apple
, Orange
and Banana
to Entity
. If that one is not specified, it will use the related_name=…
parameter [Django-doc] instead, and if that is not specified either, it uses the name of the model in lowercase, so here apple
, orange
and banana
.
Source:stackexchange.com