django-treenode
django-treenode copied to clipboard
Add `include_self=False` parameter to functions which return lists/querysets
django_mptt had a nice option to include the current node in the functions which return descendants, children, etc. It is documented here
It would be nice to be able to call get_children(include_self=True) or get_children_queryset(include_self=True), and get the node in the list as well
We have a current workaround for this that's sub-optimal as it doesn't allow us to work with a queryset after defining this.
node_children_including_self = [*node.get_children_queryset(), node]
@jvacek the request is clear, frankly I don't like very much the fact that self is not a children, so including it in the result is not logically correct... and what is the right position of self in the result? start or end?
I don't like very much the fact that
selfis not a children
Fair enough, the naming convention of this is not exactly the clearest in mptt either, I had to check the docs to see what it meant. The wording doesn't matter, but functionally it would be nice to have an option to include self in the resulting list/qset
and what is the right position of self in the result? start or end
I would assume that this would follow the traversal method you've chosen. If that's pre-order, then it would be at the start.