The `modified` field of `TimeStampedModel` may be unupdated on Django >= 4.2

Author: interDistCreated Nov 8, 2025Updated Dec 10, 2025

Django 4.2 changed the requirements for the Model.save() method: “any fields modified in the custom save() methods should be added to the update_fields keyword argument before calling super()” (https://docs.djangoproject.com/en/stable/releases/4.2/#setting-update-fields-in-model-save-may-now-be-required).

When updating my code and tests for this new requirement, I noticed that the TimeStampedModel does not fulfil it. If the save() method of my model based on TimeStampedModel is called with the update_fields argument, the modified field is not saved to the database, as can be anticipated. By the way, this is also applicable to the ActivatorModel but my code does not make use of it.

P.S. All my custom save methods on the models include now the update_fields kwarg and code similar to the following:

python
        if update_fields:
            update_fields = [*update_fields, 'calculated_field_one', 'calculated_field_two']

Django’s documentation offers yet another manner to grow update_fields if it is not None:

python
            update_fields = {'calculated_field_one', 'calculated_field_two'}.union(update_fields)

Source: django-extensions/django-extensions