Reputation: 9636
I have changed the save method to include a modified date field to changed on all saves. I want to know if I update the model using update() method. Will the save method be called??
Please answer explaining if not than how can I update the modified date field on all modifications
Upvotes: 0
Views: 117
Reputation: 53971
If you read the documentation on the update
method of a queryset you will notice it says the following:
Finally, realize that update() does an update at the SQL level and, thus, does not call any save() methods on your models, nor does it emit the pre_save or post_save signals (which are a consequence of calling Model.save()).
but
If you want to update a bunch of records for a model that has a custom save() method, loop over them and call save(), like this:
for e in Entry.objects.filter(pub_date__year=2010):
e.comments_on = False
# Or in your case, update the date here
e.save()
Upvotes: 2