Corrected Node's get_path method to only fetch the path since the given root (if...
authorStephen Burrows <stephen.r.burrows@gmail.com>
Fri, 19 Nov 2010 06:46:38 +0000 (01:46 -0500)
committerStephen Burrows <stephen.r.burrows@gmail.com>
Mon, 29 Nov 2010 18:24:01 +0000 (13:24 -0500)
models/base.py

index 37ab247..0598407 100644 (file)
@@ -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):