The easiest way to save Django's formwizard form_list in a database?

I created several subforms from the same model to use FormWizard in Django.

Obfuscation is part of conservation. As soon as the user finished the form, I wanted to save the information in the database. It's pretty simple with one form where I can say

one_form_from_model.save ()

But can I do this when I get the returned form_list. I read a few posts, but they made no sense to me.

Can i clear the data

form.cleaned_data for the form in form_list]

and then go through each form? But then I will need to know in what form I should find the correct fields. Isn't there an easier way to do this?

Thank you for your advice!

+4
source share
1 answer

Try something like this:

instance = MyModel() for form in form_list: for field, value in form.cleaned_data.iteritems(): setattr(instance, field, value) instance.save() 
+8
source

All Articles