Reputation: 58
I can simply overwrite the save save method like so
def save(self, *args, **kwargs):
# Do something
super(Goal, self).save(*args, **kwargs)
# Do something else
How come i can't overwrite the update method in the same way? It doesn't run any of my custom code when updating an object.
def update(self, *args, **kwargs):
# Do something
super(Goal, self).update(*args, **kwargs)
# Do something else
Upvotes: 2
Views: 1144
Reputation: 64
save method is what Django uses for updating models. the builtin save() method offers one of the most common operations for Django models: to save (i.e. create or update)
You can override Update method of Django queryset
super(GoalQuerySet,self).update(*args, **kwargs)
Upvotes: 3