mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
defaulting the url prefix to / if it can't find the category tree
This commit is contained in:
parent
7f8e303a95
commit
addb0e410f
1 changed files with 6 additions and 1 deletions
|
|
@ -54,9 +54,14 @@ class Category(CategoryBase):
|
|||
|
||||
def get_absolute_url(self):
|
||||
"""Return a path"""
|
||||
from django.core.urlresolvers import NoReverseMatch
|
||||
|
||||
if self.alternate_url:
|
||||
return self.alternate_url
|
||||
prefix = reverse('categories_tree_list')
|
||||
try:
|
||||
prefix = reverse('categories_tree_list')
|
||||
except NoReverseMatch:
|
||||
prefix = '/'
|
||||
ancestors = list(self.get_ancestors()) + [self, ]
|
||||
return prefix + '/'.join([force_unicode(i.slug) for i in ancestors]) + '/'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue