mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
Added a Meta class for proper plural naming
This commit is contained in:
parent
e1b53aefcb
commit
a240fef950
1 changed files with 7 additions and 3 deletions
|
|
@ -38,19 +38,23 @@ class Category(MPTTModel):
|
|||
default="",
|
||||
help_text="(Advanced) Any additional HTML to be placed verbatim in the <head>")
|
||||
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""Return a path"""
|
||||
prefix = reverse('categories_tree_list')
|
||||
ancestors = list(self.get_ancestors()) + [self,]
|
||||
return prefix + '/'.join([force_unicode(i.slug) for i in ancestors]) + '/'
|
||||
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'categories'
|
||||
unique_together = ('parent', 'name')
|
||||
ordering = ('tree_id', 'lft')
|
||||
|
||||
class MPTTMeta:
|
||||
verbose_name_plural = 'categories'
|
||||
unique_together = ('parent', 'name')
|
||||
ordering = ('tree_id', 'lft')
|
||||
order_insertion_by = 'name'
|
||||
|
||||
|
||||
def __unicode__(self):
|
||||
ancestors = self.get_ancestors()
|
||||
return ' > '.join([force_unicode(i.name) for i in ancestors]+[self.name,])
|
||||
|
|
|
|||
Loading…
Reference in a new issue