Take the 2-minute tour ×  I have the following tree structure:
Cat 1 --Sub Cat 1 --Sub Cat 2 Cat 2 --Sub Cat 1 --Sub Cat 2
----Subsub Cat 1  Using django-mptt I'm able to display this
information using 1 query which is great, but when trying to
create a url like:   It is doing a SQL lookup for each of the
categories in my tree to get the parent nodes slug (which is
understandable.) Here is my code:      def
get_absolute_url(self):         if not getattr(self, '_slug',
None):             url = self.slug             for ancestor in
self.get_ancestors(ascending=True):                 url = url +
ancestor.slug + u'/'             self._slug = url
return ('catalogue_category', [str(self._slug)])  Is there any
functionality of MPTT that will allow me to create a url slug
without going crazy on the SQL?  share|improve this question Are
you sure that there's one query per parent? The whole point of
MPTT is that queries like this are cheap. get_ancestors, in
particular, is one single query. Can you check (