Fix saving Course model

remotes/origin/hasaccess
Ivlev Denis 8 years ago
parent ed0e0fa34a
commit e24efc7f6d
  1. 12
      apps/course/models.py

@ -75,9 +75,15 @@ class Course(models.Model):
update_at = models.DateTimeField(auto_now=True)
def save(self, *args, **kwargs):
print(self.title)
self.slug = slugify(self.title[:100] + '_' + str(uuid4())[:6], allow_unicode=True)
print(self.slug)
if not self.slug:
self.slug = slugify(
self.title[:100],
allow_unicode=True
)
if Course.objects.filter(slug=self.slug).exists():
self.slug += '_' + str(uuid4())[:6]
return super().save()
@property

Loading…
Cancel
Save