Open yakovyarmo opened 4 months ago
Yeah, you can do something like
from django.db.models.expressions import RawSQL
Node.objects.with_tree_fields().values(
tree_depth=RawSQL("tree_depth", ()),
tree_path=RawSQL("tree_path", ()),
)
Note though that this only returns an array for tree_path
when using PostgreSQL, other DB engines will return the internal representation used by django-tree-queries because those DB engines do not support arrays as a native datatype. Also, the representation of those values is subject to change, so please don't rely on them too much. This has already bitten other people in the past, see #65
Hi, Is there any way to get tree_path and tree_depth on values() call? for example:
Node.objects.with_tree_fields().values()
or
Node.objects.with_tree_fields().values('tree_depth')