[Answer]-Batch union of django querysets

1👍

Without seeing your models it’s hard to tell, but it seems that your TemplateFolder model is some sort of tree structure. If that’s so, you should investigate using something like MPTT to store it in the database: that’s an algorithm that annotates a description of the tree structure, in terms of left and right node values, onto each row, and so makes querying everything under a specific parent extremely efficient. There’s a great Django implementation: django-mptt.

Leave a comment