I'm using formsets fairly successfully (thanks very much to Malcolm's
great quiz example), but it seems to me there is some functionality
missing.    Say I create a formset of BookForms, where BookForm is a
ModelForm.  The user will filleout the formset and for each form in
the formset, when I receive the POST data I will create an instance of
a Book based on that data.

I can't use a modelform_factory because when I create the formset, I
don't have any book objects yet (which I would need to set the
queryset for the modelform_factory).  So instead I use a
formset_factory that references a BookForm that is derived from a
ModelForm.  However, when I use a formset_factory, I don't have a nice
way to save the forms in my formset as new book objects.  For example,
when I use just a ModelForm, I can do

bookForm = BookForm(postDict)
newBookObj = bookForm.save()

When I use the formset, I can loop through the forms in the formset,
but then I think I have to create the book objects myself.

for form in bookFormSet.forms:
    newBookObj = Book(title=form.cleaned_data['title'])

If I add fields to my book model, I would have to now rememeber to
copy them inside this loop.

Have I missed something?

Margie

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to