fix Tag creation via admin erroring because slug field is not filled

This commit is contained in:
Nick Sweeting 2024-10-14 17:38:53 -07:00
parent c0b7887fd7
commit 1d7f0ab20d
No known key found for this signature in database

View file

@ -82,9 +82,13 @@ class Tag(ABIDModel):
if i is not None:
slug += "_%d" % i
return slug
def clean(self, *args, **kwargs):
self.slug = self.slug or self.slugify(self.name)
super().clean(*args, **kwargs)
def save(self, *args, **kwargs):
if self._state.adding and not self.slug:
if self._state.adding:
self.slug = self.slugify(self.name)
# if name is different but slug conficts with another tags slug, append a counter