Overriding the formset save method/ Inlineformsets with 2 related Models
I have a bunch of inline formsets, which are related to two models. In this case I want to have a bunch of "Dealings" associated with a "Report" and a "Question".
So I can associate them to one fairly easily.
DealingFormset = inlineformset_factory(Report, Dealing, form = DealingForm)
So to associate the Dealing with the Question I do it when I save the form.
104 dealings = formset.save(commit = False)
105 for deal in dealings:
106 deal.question = question
107 deal.save()
I wanted to move the second snippet to a method on the DealingForm. However, when I try to override the save on the form, I get an exception saying that the formset received an unexpected argument.
Is there a way to either at the beginning, associate an inlineformset with 2 models? Or, is there a way to override the formset save method to accept my new argument?
Thanks
-- 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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home