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
My company uses simple history as well. I found a solution to display the correct inlines in the admin (sketched below).
If you are interested in the solution, I would obtain approval from my company to contribute the solution.
However, the solutions has some workarounds that would be nice to be replaced firstly:
Always Save Inlines: All inlines have to be saved whenever the parent model is saved (solved by AlwaysSaveForm in the inline class). It would be better to handle this directly within django-simple-history.
Save Order: The standard Django save order has to be used (Parent first, Children afterward)
Solution Overview
Prerequisites:
Inlines are always within a ForeignKey relationship (Child points to Parent)
HistoricalModels deliver a version field history_id
When a Parent is changed a new historical parent record with a history_id is created
When modifying the inlines of a Parent, only the affected Children will have a new historical record
Implementation:
Always Save Inlines: Use an AlwaysSaveForm to ensure all Children are saved whenever the Parent is saved.
Mapping: For each foreign key of a Child add a new field in the historical child model to create a mapping to the Parent history_id:
Distiguish by history_type of Child: "No change", "Created (+)", "Deleted (-)", "Modified (~)"
If "No change" or "Created (+)" or "Modified (~)" then add latest Parent history_id
My company uses simple history as well. I found a solution to display the correct inlines in the admin (sketched below).
If you are interested in the solution, I would obtain approval from my company to contribute the solution.
However, the solutions has some workarounds that would be nice to be replaced firstly:
AlwaysSaveForm
in the inline class). It would be better to handle this directly withindjango-simple-history
.Solution Overview
Prerequisites:
history_id
history_id
is createdImplementation:
history_type
of Child: "No change", "Created (+)", "Deleted (-)", "Modified (~)"The text was updated successfully, but these errors were encountered: