Re: Updating parent record, when child record changes
On 6/12/2011 8:40pm, zobbo wrote:
> I asked a similar question last week but got no responses - here's a
> related but hopefully simpler question.
>
> What is the recommended way to update a field on a parent record when
> one or more of it's child records (held in inlines) are modified? I
> could hook on post_save on the inlines, but if you have 50 inline you
> only really want to do the processing at the end of the last inline
> record to be saved.
>
> I want to update a status field on the parent record, whose value will
> vary depending on the child records.
I think I would implement a post_save signal[1] on the child and
register a listener[2] for that signal on the parent. When detected it
could trigger a parental review of the children (or child) and that
would take whatever action you want.
[1]
https://docs.djangoproject.com/en/1.3/ref/signals/#django.db.models.signals.post_save
[2]
https://docs.djangoproject.com/en/1.3/topics/signals/#listening-to-signals
Mike
>
> Ian
>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home