Easiest way to save Django´s formwizard form_list in DB?

前端 未结 1 1502
挽巷
挽巷 2021-02-10 18:42

I have created multiple sub-forms from one model to use the FormWizard in Django.

Confusing is the saving part. Once the user finished the form, I wanted to save the inf

相关标签:
1条回答
  • 2021-02-10 18:48

    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()
    
    0 讨论(0)
提交回复
热议问题