mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
Added some specialized functions for relations
This commit is contained in:
parent
8d466591d5
commit
0fa7402f1d
1 changed files with 14 additions and 0 deletions
|
|
@ -49,6 +49,20 @@ class Category(MPTTModel):
|
|||
ancestors = list(self.get_ancestors()) + [self,]
|
||||
return prefix + '/'.join([force_unicode(i.slug) for i in ancestors]) + '/'
|
||||
|
||||
if RELATION_MODELS:
|
||||
def get_related_content_type(self, content_type):
|
||||
"""
|
||||
Get all related items of the specified content type
|
||||
"""
|
||||
return self.storyrelation_set.filter(
|
||||
content_type__name=content_type)
|
||||
|
||||
def get_relation_type(self, relation_type):
|
||||
"""
|
||||
Get all relations of the specified relation type
|
||||
"""
|
||||
return self.storyrelation_set.filter(relation_type=relation_type)
|
||||
|
||||
class Meta:
|
||||
verbose_name_plural = 'categories'
|
||||
unique_together = ('parent', 'name')
|
||||
|
|
|
|||
Loading…
Reference in a new issue