So I have two models (Tables) related by a ForeignKey. In the admin, the edit page displays the first model (let's say ModelOne) along with the related instances of the second model, ModelTwo (TabularInline).
What I want is perform some additional actions when the second model is being changed. I can do this with a post_save signal on ModelTwo. However, the post_save signal is only called when I save the model from within its own edit page (ie. not within ModelOne's inlines).
Is there a way to attach a post_save signal on ModelTwo's inline form?
...As a workaround I added some custom validation to ModelTwo, which is being called regardless if it's inline or not), to call the method I want. However, the problem that arises from this setting is that if am creating a new instance of ModelOne and also create instances of ModelTwo at the same time I cannot access the primary key (foreign key) of the new instance that relates the two tables (since it has not been saved yet). And the primary key is something I need.
I also tried adding a post_save signal to ModelOne directly (so that I can get the new instance's PK) but it seems that the post_save signal does not pass ModelTwo's data (and why should it, anyway?)
So what's the solution to this? Do inline models emit signals? Is there a way to access the PK of the new instance before saving it?