Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inline admins #438

Open
merwok opened this issue Sep 25, 2018 · 5 comments
Open

Support inline admins #438

merwok opened this issue Sep 25, 2018 · 5 comments
Labels
accepted Issue accepted for completion enhancement

Comments

@merwok
Copy link

merwok commented Sep 25, 2018

Problem Statement

Not sure if this is a bug or feature: inline admins can't be displayed in the admin form view.

Describe the solution you'd like

Port PR #315 to add "inline_admin_formsets" in context to make them available.

Describe alternatives you've considered

Additional context

@pallavg
Copy link

pallavg commented Apr 10, 2020

Good evening - Was wondering if there was any progress on this enhancement. We are using this app in our project. It works very well, but are not able to see the changes in the admin view for inline admins. It is not a big deal but since this ticket is open, was curious . Thank you.

@rossmechanic
Copy link
Collaborator

Haven't look at it – but if you want to take a stab at it, I'd be happy to look at your pr @pallavg

@hatiq-ssi
Copy link

Was this enhancement added? I am using inline on my admin form but it is not visible in the history.

@frobert
Copy link

frobert commented Aug 2, 2024

would be really great to have. Are there any workarounds or temp solutions?

@tomH01
Copy link

tomH01 commented Oct 17, 2024

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:

  1. Always Save Inlines: Use an AlwaysSaveForm to ensure all Children are saved whenever the Parent is saved.
  2. 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
  • Else change nothing
  • Display the Inlines: Display the inlines with parts of Add support for admin inlines #315 while filtering them by their mapping field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue accepted for completion enhancement
Projects
None yet
Development

No branches or pull requests

6 participants