Update a single field on a Django model
May 19, 2021 ‐ 1 min read
Updating a single field in Django might have your preference over updating all model fields to the database. This is somewhat more beneficial in terms of performance for example. You specify the fields that should be updated by passing the update_fields
keyword argument to the .save()
method containing a list of field names.
user.is_active = False
user.save(update_fields=['is_active])
Of course Django provides excellent docs on this particular feature.