Added slugify to create collection

This commit is contained in:
dormantman 2019-12-17 21:13:10 +03:00 committed by Kuroshini
parent 23299ad4a1
commit 5a18be4584
2 changed files with 11 additions and 0 deletions

View File

@ -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."""

View File

@ -63,3 +63,6 @@ pycountry==19.8.18
# sql-tree
django-mptt==0.9.1
# slugify
python-slugify==4.0.0