Login

Tag "update_fields"

Snippet List

Model Mixin to Save Only Changed Fields

**[Improved and Released as Save The Change.](https://github.com/karanlyons/django-save-the-change)** Django 1.5 added the `update_fields` `kwarg` to `Model.save()`, which allows the developer to specify that only certain fields should actually be committed to the database. However, Django provides no way to automatically commit only changed fields if they're not specified. This mixin keeps track of which fields have changed from their value in the database, and automatically applies `update_fields` to update only those fields.

  • model
  • save
  • mixin
  • class
  • automatic
  • update_fields
Read More

1 snippet posted so far.