Hi fellow Django developers,

using a model with several related models, for the Django Admin I have a ModelAdmin that uses several InlineModelAdmin objects, very much as in the example at <https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#inlinemodeladmin-objects>.

All works well, but when the user clicks the "Save" button in the change view, I would like to find out if anything has changed in the parent model or the related (inline) models, and depending on the result, update one of the parent model's fields before it is saved.

Can you please tell me how can this be achieved?


In more detail, having read all of https://docs.djangoproject.com/en/1.7/ref/contrib/admin/ and thinking that I have understood most of it, the ModelAdmin methods

    save_model()
    save_formset()
    save_related()

seem to be the right approach to my problem, but are a complete mystery to me: How are the related to each other, and what is their purpose?

The documentation of all three begins with "The save_* method is given the HttpRequest, ...", but what follows it too sparse for my still limited Django knowledge, and unfortunately I cannot see yet the bigger picture about them, or how to proceed from there.

Could someone please explain how these methods work, when they are called, etc.?


A huge thanks in advance and best regards,
Carsten

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54930CBE.5010608%40cafu.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to