From: Stephen Burrows Date: Fri, 19 Nov 2010 06:46:38 +0000 (-0500) Subject: Corrected Node's get_path method to only fetch the path since the given root (if... X-Git-Tag: philo-0.9~25^2~1^2~1 X-Git-Url: http://git.ithinksw.org/philo.git/commitdiff_plain/572eaacd575a0c80e478d8ba841e56c5ca43351c?ds=inline Corrected Node's get_path method to only fetch the path since the given root (if any) --- diff --git a/models/base.py b/models/base.py index 37ab247..0598407 100644 --- a/models/base.py +++ b/models/base.py @@ -405,7 +405,12 @@ class TreeModel(MPTTModel): if root is not None and not self.is_descendant_of(root): raise AncestorDoesNotExist(root) - return pathsep.join([getattr(parent, field, '?') for parent in list(self.get_ancestors()) + [self]]) + qs = self.get_ancestors() + + if root is not None: + qs = qs.filter(level__gt=root.level) + + return pathsep.join([getattr(parent, field, '?') for parent in list(qs) + [self]]) path = property(get_path) def __unicode__(self):