Closed peter-stuart-turner closed 2 years ago
Hi
There's no easier way to know the position of the node in the tree without building the whole tree structure in the database. Not without denormalization.
Got it, thanks
Sorry, what I wrote above isn't completely correct. A simpler recursive CTE for fetching the depth is possible of course but django-tree-queries doesn't have any support for this.
Thanks!
I am having to use the queryset method:
TreeNode.objects.filter(id=node.id).with_tree_fields().first().tree_depth
but is there an easier way to access - I am wanting to serialize it within Django Rest framework