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 _historyid:
Distiguish by history_type of Child: "No change", "Created (+)", "Deleted (-)", "Modified (~)"
If "No change" or "Created (+)" or "Modified (~)" then add latest Parent _historyid
Else change nothing
Display the Inlines: Display the inlines with parts of #315 while filtering them by their mapping field.
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 (~)"