Need to be able to access serialized data from changed object
See original GitHub issueWe need to be able to access a serialized dictionary of an object’s field values following a change. I’d like to add a serialized_data
JSON field to the LogEntry
model. That field will be populated by the receivers which will implement django.core.serializers
to serialize the new state of the object after a change.
Having a historical record of object states will help us to be able to recover from several types of potential data loss events and aid us in debugging system artifacts. It is also critical to help us to determine calculated values for post hoc analysis and reporting. For example, if we need to determine who had x insurance and lived in y state at z time, we can use the audit log to determine what the person had listed as their state of residence at time z without needing a separate one to many historical model for state of residence.
There are a lot of helpful public facing APIs that could be added to the project using this field as a foundation (e.g., get_field_value_at_time(field_name, timestamp)
) but the first step is to create the serialized_data
field itself. Also note that I am aware there are other packages out there, such as django-reversions, that do this. However, in our experience they don’t fit our needs as a first-class audit log.
I am adding this functionality to our fork but would love it if you would consider adding it to the project. Please let me know if there is anything I can do to make that more likely. Look for my PR later today!
cc @hramezani
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Trust me I understand that ongoing maintenance and it’s impact in the OSS world and I thank you all deeply for the work that you do on this, and all the other projects you may work on. ❤️
Though, I do think that the saving of the serialized value can be considered low effort as long as Django itself is managing the serialization.
We are also happy to keep the surface area of the API smaller by removing things such as
get_field_value_at_timestamp
, if it removes some maintenance burden on you all.@hramezani I figured the best way to show you my thoughts was in the PR. Take a look at what I’ve submitted and let me know what you all think. I’m happy to make changes if it has a better chance of getting merged!