Reputation: 11496
I have a tree model for categories like this:
from treebeard.mp_tree import MP_Node
class Category(MP_Node):
...
And I want to get a queryset with only the leaf nodes.
Upvotes: 0
Views: 784
Reputation: 11496
MP_Node
has a field called numchild
, which stores the amount of children each node has, so you can get a queryset of all leaf nodes like this:
Category.objects.filter(numchild=0)
Upvotes: 2