Re: updating parent model on inline creation
On nov. 14, 02:13, Preston Holmeswrote: > I'm setting up a conference website where a submission will have one > or more "reviews" > > I've got the reviews set as inlines for submissions in the admin > > The submission model has a "status" field that needs to go through > steps like "submitted" and "pending review" > > What I'd like to do is when the first review is created via the > inline, update the status on the parent submission model. > > I thought of two ways to do this. > > The first more complicated way would be to right my own view for this > with subclassed formset handling that would do this. > > The second idea which I now am liking better should also work: > > register a funciton for post_save signals on the submission model, and > then (in pseudo code) > > if submission.status == "submitted" and submission.reviews.count > 0: > submission.status = "pending review" > > If this were a busy site - the signal based system might be heavy on > the database, but this is a project where we will never see real load. > > Are there even simpler ways to do this that I haven't thought of? > > -Preston sure, if this is REALLY a requirement, then build it into your model's save method when you save the review, set the submission status directly from the save method, not via signals V -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Re: updating parent model on inline creation
On Nov 13, 5:13 pm, Preston Holmeswrote: > if submission.status == "submitted" and submission.reviews.count > 0: > submission.status = "pending review" > > Are there even simpler ways to do this that I haven't thought of? answering myself - sorry: I should just put that logic in the review.save method - no signal needed > > -Preston -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
updating parent model on inline creation
I'm setting up a conference website where a submission will have one or more "reviews" I've got the reviews set as inlines for submissions in the admin The submission model has a "status" field that needs to go through steps like "submitted" and "pending review" What I'd like to do is when the first review is created via the inline, update the status on the parent submission model. I thought of two ways to do this. The first more complicated way would be to right my own view for this with subclassed formset handling that would do this. The second idea which I now am liking better should also work: register a funciton for post_save signals on the submission model, and then (in pseudo code) if submission.status == "submitted" and submission.reviews.count > 0: submission.status = "pending review" If this were a busy site - the signal based system might be heavy on the database, but this is a project where we will never see real load. Are there even simpler ways to do this that I haven't thought of? -Preston -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.