You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Historical records: set the change reason explicitly on the instance (#8627)
The implementation of django-simple-history's `update_change_reason`
is very brittle, as it queries for a previous historical record
that matches the attributes of the instance to update the ``change_reason``,
which could end up updating the wrong record, or not finding it.
https://github.com/jazzband/django-simple-history/blob/b8e43df626a03ce4817beaf6a20995b40a209f37/simple_history/utils.py#L27
I saw this mostly happening when:
- Saving a team without changing anything (update_change_reason won't
find the record for some reason)
- Deleting a team (update_change_reason will override the previous
record instead)
But simple history also mentions that you can set the change reason
explicitly by setting the `_change_reason` attribute,
which is more safer as it sets the change_reason at the creation time of
the record.
https://django-simple-history.readthedocs.io/en/latest/historical_model.html#change-reason
0 commit comments