1π
β
I think it can be done with annotate and exact djangoβs directives.
It can be done even simpler. You can filter with:
Critters.objects.filter(parent=None, critters=None)
We thus filter on the reversed relation. This is a LEFT OUTER JOIN
and then check if that is None
. It will thus make a query that looks like:
SELECT *
FROM critters
LEFT OUTER JOIN critters AS c ON c.parent_id = critters.id
WHERE parent_id IS NULL AND c.id IS NULL
0π
Kinda confused what you trying to do.
If want to select all value where parent not exist, you can achieve it by doing this:
Critters.objects.filter(parent=None)
There also .exclude
you can use.
π€GoodDay
- [Answered ]-How to make on update record pass the signal in Django Model?
- [Answered ]-Django activation custom email text does not appear
- [Answered ]-When I try a syncdb, where is the duplicate user_id error coming from?
Source:stackexchange.com