Closed atodorov closed 4 years ago
The tree_*
fields aren't known to the Django query machinery and therefore cannot be used with .order_by()
unfortunately. You have to go through the .extra()
API. I added a test here which demonstrates a hopefully correct BFS ordering: https://github.com/matthiask/django-tree-queries/commit/1f144107ffef197d78083523c40f1a58ce0e8a91
Thanks for the tip & the test. That works for me.
I want to generate a nested HTML list structure and the easiest way would be to have the tree nodes sorted in BFS order. Or be able to
.order_by('tree_depth')
on the resulting query.Instead I can call
.order_by('__tree.tree_depth')
but that seems to have no effect.