Why Is My Overridden Save Method Not Running In My Django Model?
I have this model class Clinic(models.Model): name = models.CharField(max_length=100) email = models.EmailField(blank=True) website = models.URLField(blank=True) ph
Solution 1:
Try this one:
defsave(self, *args, **kwargs):
self.slug = slugify(self.name)
super(Clinic, self).save(*args, **kwargs)
But if you want to populate slug only once on creation:
defsave(self, *args, **kwargs):
ifnotself.pk:self.slug = slugify(self.name)
super(Clinic, self).save(*args, **kwargs)
Post a Comment for "Why Is My Overridden Save Method Not Running In My Django Model?"