Edit two related models on one form
Hello,
I have a pretty basic problem that I cannot find any reference for to solve. Let's say I have the following relationship scenario: question and answer, where each question may have up to four answers, but each answer can only have one question. I concluded to put a ForeignKey on the answer model.
The problem, however, comes when I want to add a new question. Currently, I would need to first add a question by itself and afterwards create new answers and reference the question. Optimally, I would like to be able to create the necessary answers right from the question form and associate them with the question upon saving. This of course also implies that upon load a form for a certain question, the already associated answers will be loaded.
Do I handle the form logic in a ModelForm subclass, on the view or is there already pluggable app for this that I missed?
Seems like this scenario would be a pretty common problem,
Felix
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ikvVkFXPhKUJ.
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