Django override model save method

# Method1 class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def save(self, *args, **kwargs): do_something() # Call the "real" save() super(Blog, self).save(*args, **kwargs) do_something_else() # Method2 class Blog(models.Model): name = models.CharField(max_length=100) tagline = models.TextField() def save(self, *args, **kwargs): do_something() # Call the "real" save() models.Model.save(self, *args, **kwargs) do_something_else()

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.