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

How track changes of a Model that is only included as an Inline and nowhere else (Reverse Foreign Key) #1384

Open
raayu83 opened this issue Aug 26, 2024 · 1 comment

Comments

@raayu83
Copy link

raayu83 commented Aug 26, 2024

Hello,

I have a questions regarding History management in a ModelAdmin that includes an One to Many Inline:
How do you set these up so that History of the Many side model is also shown on the main Model, in a similary way to ManyToMany Models?
I have two related Models: One for Reports, one for the E-Mail Addresses the Reports are to be sent to.

Basically they are set up like this:

class DeliveryByEmailRecipient(TimestampMixin, models.Model):
    report = HistoricForeignKey(
        "Report",
        related_name="delivery_by_email_recipients",
    )
    history = HistoricalRecords()
class Report(TimestampMixin, CloneMixin, models.Model):
    name = models.CharField(max_length=255)
    history = HistoricalRecords()

I've integrated the DeliveryByEmailRecipient Model into the Reports Admin page using an InlineAdmin.
Administration of the E-Mails works as intended, but changes are not tracked by simple-history.

I've probably an error in my setup, so I would be grateful if somebody could give me some hints.

I'm actually not even sure if I need to use HistoricForeignKey here.

Best regards

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

No branches or pull requests

2 participants
@raayu83 and others