can you use Form Wizard for Model Forms in django?

Viewed 5432

I have one model and I've created a form out of the model using ModelForm. Now, I want to spread the form across two pages. For example, the first three fields will appear on the first page then the user clicks next and the last three fields appear on the second page. Then he clicks submit and the user submitted data is added to the database.

I took a look at the docs for the Form Wizard and it seems like it would work for model forms as well? Can someone confirm this?

And if it does, can someone explain the process of creating a WizardView class.

This example is given in the docs and I don't understand what the second two parameters are. Is form_list just a list of form objects that you've instantiated based on your form classes? And what is **kwargs?

class ContactWizard(SessionWizardView):
    def done(self, form_list, **kwargs):
        do_something_with_the_form_data(form_list)
        return HttpResponseRedirect('/page-to-redirect-to-when-done/')

Thanks in advance for your help!

4 Answers
Related