I'm trying to tie django-mptt and contrib.admin together by providing something friendlier than a flat list in the admin. Because the trees are supposed to be large (otherwise i wouldn't be using nested sets), users should be able to expand and collapse parts of it.
When a user expands or collapses or expands a branch (ajax is used for that), a cookie is also set containing a comma separated list of collapsed branches. This way, next time this user visits the admin for my django-mptt powered model, i can show him the tree in the exact state he left it. Now i would like to use this list of collapsed branches to ease the burden on my database by fetching only needed parts of the tree.
Is there a way to do this effectively? The solutions i googled were making a query for each branch so they could avoid querying when a branch was collapsed, but that doesn't look very effective to me. Maybe it is possible with a fixed number of queries?