[Answered ]-Django: How can I make Form Wizard take in a request object when it creates the forms?

2👍

You can use get_form_kwargs method from SessionWizardView to add your request into form kwargs.

def process_form_data(form_list):
    form_data = [form.cleaned_data for form in form_list]

    print form_data[0]
    print form_data[1]

    return form_data
class ReviewWizard(SessionWizardView):
    template_name = "review_form.html"

    def done(self, form_list, **kwargs):
        form_data = process_form_data(form_list)

        return render("done.html", {"form_data": form_data})

    def get_form_kwargs(self, step):
        kwargs = super(ReviewWizard, self).get_form_kwargs(step)
        kwargs['request'] = self.request
        return kwargs

Leave a comment