From 572eaacd575a0c80e478d8ba841e56c5ca43351c Mon Sep 17 00:00:00 2001 From: Stephen Burrows Date: Fri, 19 Nov 2010 01:46:38 -0500 Subject: [PATCH] Corrected Node's get_path method to only fetch the path since the given root (if any) --- models/base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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): -- 2.20.1