Is there a way to present a partial tree using Django-MPTT's {% recursetree %}
without retrieving the entire tree from database? I need to show the first 20 nodes encountered by a Depth First Search.
Either of these (which do not retrieve the full tree) cause an exception:
# resulting querySet passed to {% recursetree %} in template
Thing.objects.all()[:20]
# directly sliced in template
{% recursetree all_nodes|slice:":20" %}
AssertionError while rendering: Cannot reorder a query once a slice has been taken
.
This on the other hand does work, but retrieves the entire tree:
# resulting querySet passed to {% recursetree %} in template
list(Thing.objects.all())[:20]
How can I do this without retrieving the entire tree form the DB?