| Issue 8: | get_depth (or get_level) | |
| 2 people starred this issue and may be notified of changes. | Back to list |
Type: Enhancement Priority: medium Hi, I want to suggest these functions to be added to the model and manager interface: 1. model.get_depth() : the depth of this node from root node 2. model.get_level() : alias for get_depth 2. manager.get_depth(tree_id) : the depth from the root node to the lowest leaf node Thank you.
Jan 14, 2008
Hi, Sure we can use the level field but the user'd need to look at the code first to know that there is a level field. Even so the level field is abstracted in level_attr, so it's name is not fixed. For case when we need the depth of the tree, an example is when we want to print the whole tree and we want to reserve the width of the column. Thanks.
Dec 5, 2008
get_level() should be nice! For example, I have tuned column names and use `mptt_level`, `mptt_left`, etc. instead of `level` and `lft`. Thus, for me it may be much better to use get_level() not depending on column names.
Sep 2, 2010
Added node.get_level() in http://github.com/django-mptt/django-mptt/commit/c1ee708ae8fdd377537dd5c180aec5a8ddca1490 Total depth of tree is a slow operation and I can't see it being useful in very many scenarios. Wont fix that for now.
Status:
Verified
|
Labels: -Type-Defect Type-Enhancement