Hi Scott:

Thanks for the suggestion. The 2 ModelForms suggestion is a good idea,
but I'm not clear how it will work in a formset.

Recall I'd like to make a table with each row in the table being a
"form" for a paired Author-Book item (recall my book-author is 1-1).
If I make an Author formset and a Books formset and then render them
in the template it's not clear to me that the book part of the form
would in fact correspond to the author part of the form. Actually... I
expect I'd need to have nested for loops to loop over both formsets
and that is not what I want...
{% for AuthorForm in AuthorFormset.forms %}
{% for BookForm in BookFormset.forms %}
<tr><td><AuthorForm</td><td>BookForm</td></tr>
{% endfor %}
{% endfor %}
will not give the desired result.

Regarding the one form idea... I'm new enough to django that it's not
clear to me how to "pre-populate" the formset in that case with the
data from the database. While I'm aware of the "initial" parameter in
the formset constructor it doesn't appear that was meant to initialize
a form with rows from a database. So it seems that I'd lose the
information that my initial data actually corresponds to items that
already exist in the database.

Thoughts?

Mike

> Two main ways to do this:
>
>   - two ModelForms, one for each model, and display/process them both
> together
>   - one Form, with a custom save() that creates the two objects
>
> I haven't done formsets with multiple forms before, so I don't know
> how easy/possible that is. The second option should certainly work
> fine in a formset setting, though.
>
> Regards
> Scott
>
> --
> 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 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
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=en.

Reply via email to