Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的类别的树模型:
from treebeard.mp_tree import MP_Node class Category(MP_Node): ...
我想得到一个只有叶节点的查询集。
MP_Node有一个名为 的字段numchild,它存储每个节点的子节点数量,因此您可以获得所有叶节点的查询集,如下所示:
MP_Node
numchild
Category.objects.filter(numchild=0)