I want to create an Entity Group relationship in an Entity that is being created through a ModelForm.
How do I pass the parent instance and set the parent= attribute in the ModelForm?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’ll be interested to see if you get any good solutions to this problem. My own solution, which is far from elegant, is to do this:
Basically, I first create a dummy object (
chapterin this case) with the correct parent relationship and then pass that as theinstanceargument to the form’s constructor. The form will overwrite the throwaway data I used to create the dummy object with the data given in the request. At the end, to get the real child object, I do something like this: