[Answered ]-Save method in django views.py not working after overriding it in models,py

1👍

The self.slug has default = "" so in the save method it doesn’t enter the condition, so the super doesn’t work, I recommend modifying the save method for that:

        def save(self, *args, **kwargs):
            if self.slug is None or self.slug == "":
                year = datetime.today().year
                self.slug = slugify(str(year) + '-' + str(self.category) + '-' + str(self.title))
            super(Blog, self).save(*args, **kwargs)

Leave a comment