From 1d7f0ab20ddb3e98a1cfa3b163c0add20563d967 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Mon, 14 Oct 2024 17:38:53 -0700 Subject: [PATCH] fix Tag creation via admin erroring because slug field is not filled --- archivebox/core/models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/archivebox/core/models.py b/archivebox/core/models.py index b00aae4e..327d2c5b 100644 --- a/archivebox/core/models.py +++ b/archivebox/core/models.py @@ -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