# Why doesn't django only UPDATE the fields that are changed?

**URL:** <https://forum.djangoproject.com/t/why-doesnt-django-only-update-the-fields-that-are-changed/28731>\
**Category:** ORM\
**Created:** [March 5, 2024, 11:41am UTC](https://forum.djangoproject.com/t/why-doesnt-django-only-update-the-fields-that-are-changed/28731 "2024-03-05T11:41:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arpitpatel1771](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/arpitpatel1771/32/19650_2.png) [@Arpitpatel1771](https://forum.djangoproject.com/u/Arpitpatel1771)\
**Post date:** [March 5, 2024, 11:41am UTC](https://forum.djangoproject.com/t/why-doesnt-django-only-update-the-fields-that-are-changed/28731/1 "2024-03-05T11:41:16Z")

</div>

I recently discovered the fact that Django will generate the UPDATE statement for each and every column of that table, when i call save, even though only 1 or 2 fields have been updated. But when you pass update\_fields to .save(), it will generate queries taking into account those fields too. **So, why doesn’t Django do this by default?** Surely there must be a better way to check if an attribute has been changed and then only generate an UPDATE query for that statement.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 5, 2024, 12:07pm UTC](https://forum.djangoproject.com/t/why-doesnt-django-only-update-the-fields-that-are-changed/28731/2 "2024-03-05T12:07:13Z")

</div>

> [@Arpitpatel1771](#):
>
> So, why doesn’t Django do this by default?

There have been previous threads on this - see [Automatically setting update\_fields when saving a model instance](https://forum.djangoproject.com/t/automatically-setting-update-fields-when-saving-a-model-instance/26798) for what I think is the most recent one.

The brief answer is that it exposes your application to a wider range of race-condition errors. So it’s safer to save the entire object.

---

<div class="post-metadata">

**Author:** ![Arpitpatel1771](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/arpitpatel1771/32/19650_2.png) [@Arpitpatel1771](https://forum.djangoproject.com/u/Arpitpatel1771)\
**Post date:** [March 5, 2024, 1:28pm UTC](https://forum.djangoproject.com/t/why-doesnt-django-only-update-the-fields-that-are-changed/28731/3 "2024-03-05T13:28:58Z")

</div>

I see, thanks for pointing me to the topic. Thanks!
