Hello,
I understand that Django won't let you save incomplete fields in a
single form created from a Model unless you do this:
tmpform = form.save(commit=False)
tmpform.foo = form.cleaned_data['foo']
tmpform.save()
So I want to do this kind of thing with forms in a formset - I am
trying to to iterate through all the fields for each form in the
formset. But the problem is that I'm not sure exactly how to iterate
through all the fields of each form in the formset. I tried this:
for form in formset.forms:
for name, field in form.fields.items():
tmpform = form.save(commit=False)
tmpform.field[name] = form.cleaned_data[name] # doesn't work,
I get an error
tmpform.save()
But I only get the ERROR message:
'FooForm' object has no attribute 'field'.
My question is: how do I use form.save(commit=False) properly given
that I have multiple fields in a form with different field names?
Thanks in advance!
Paul
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---