There are usecases where we want to update a field in Django model but don't want to invoke model validations.
Suppose we have User model and we want to update the last_seen field for a particular user. We also have a modified_at field which gets auto updated whenever the model's save method is called.
|
|
if we update the last_seen field, the modified_at field gets auto updated
|
|
Now, we will use the update_fields
option to update only selected field in model.
|
|
As seen above, only last_seen field gets update and our save() method code is not executed.