(removed n. )
>
> On Wed, Apr 20, 2011 at 9:41 AM, Craig de Stigter <
craig...@gmail.com>wrote:
>
>
>
>
>
>
>
> > DK
>
> > That's not in django-mptt, but it's easy enough to implement using Q
> > objects. This takes 2 queries (one to evaluate your some_nodes queryset, and
> > another to fetch descendants.)
>
> > Something like this:
>
> > from django.db.models import Q
> > import operator
> > def get_queryset_descendants(nodes, include_self=False):
> > if not nodes:
> > return Node.tree.none()
> > filters = []
> > for n in nodes:
> > lft, rght = n.lft, n.rght
> > if include_self:
> > lft -=1
> > rght += 1
> > filters.append(Q(tree_id=n.tree_id, lft__gt=n.lft,
> > rght__gt=n.rght))
> > q = reduce(operator.or_, filters)
> > return Node.tree.filter(q)
>
> > Also see this thread for a similar question (with a similar solution):