Added slugify to create collection
This commit is contained in:
parent
23299ad4a1
commit
5a18be4584
|
|
@ -13,6 +13,8 @@ from utils.models import (
|
|||
from utils.querysets import RelatedObjectsCountMixin
|
||||
from utils.models import IntermediateGalleryModelMixin, GalleryModelMixin
|
||||
|
||||
from slugify import slugify
|
||||
|
||||
|
||||
# Mixins
|
||||
class CollectionNameMixin(models.Model):
|
||||
|
|
@ -140,6 +142,12 @@ class Collection(ProjectBaseMixin, CollectionDateMixin,
|
|||
|
||||
return related_objects
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not self.pk:
|
||||
slugify_slug = slugify(self.name)
|
||||
self.slug = slugify_slug
|
||||
super(Collection, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class GuideTypeQuerySet(models.QuerySet):
|
||||
"""QuerySet for model GuideType."""
|
||||
|
|
|
|||
|
|
@ -63,3 +63,6 @@ pycountry==19.8.18
|
|||
|
||||
# sql-tree
|
||||
django-mptt==0.9.1
|
||||
|
||||
# slugify
|
||||
python-slugify==4.0.0
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user