Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add include_self=False parameter to functions which return lists/querysets #46

Open
jvacek opened this issue Nov 5, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@jvacek
Copy link
Contributor

jvacek commented Nov 5, 2021

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

Fund with Polar
@jvacek jvacek added the enhancement New feature or request label Nov 5, 2021
@jvacek
Copy link
Contributor Author

jvacek commented Nov 5, 2021

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]

@fabiocaccamo
Copy link
Owner

@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?

@jvacek
Copy link
Contributor Author

jvacek commented Nov 5, 2021

I don't like very much the fact that self is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

2 participants