defaulting the url prefix to / if it can't find the category tree

This commit is contained in:
Corey Oordt 2015-06-09 15:17:21 -05:00
parent 7f8e303a95
commit addb0e410f

View file

@ -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]) + '/'