title: Django: How can I make Form Wizard take in a request object when it creates the forms?
body: <p>How can I make it so that when Django's Form Tool's Wizard creates my forms, it also gives <code>request</code> object as a parameter? The main reason why I'm using Form Tool is to have a multi-page form. Right now to "normally" create my <code>AnswerForm</code> without the Wizard, it looks like </p>
  
  <pre><code>form = AnswerForm(request=request)
  </code></pre>
  
  <p>I'm taking in <code>request</code> because inside the form, I want to keep track of a key called <code>'question'</code> in <code>request.session</code>. (The purpose of this key is to make sure that I can keep track of the <code>Question</code> model instance that is associated with the <code>Answer</code> instance that I'm trying to create through this form. I'm actually not sure if this is a good way to do this. Tips?) Anyway, right now I'm getting an error that seems to mean that somewhere in my <code>ReviewWizard</code>, <code>request</code> is not a parameter when the <code>AnswerForm</code> is created. I've read about how <code>instance_dict</code> can be used in the Wizard's <code>as_view()</code> in <code>urls.py</code>, but I don't think it would help in this case since the <code>request</code> object isn't available in <code>urls.py</code>. Can anyone help me with this? Or do you know of a better approach to do what I'm trying to do in general? Thanks for your help!!</p>
  
  <p>(Ultimately the reason why I'm trying to keep track of <code>Questions</code> with <code>Answers</code> through <code>request.session</code> is because I think that when the first form a person sees shows up, it's a different instance from the form that gets POSTed. Since my <code>setup()</code> gets a random <code>Question</code>, it will probably not match up with the <code>Question</code> of the POSTed form, but maybe there's a better approach to all of this?? )</p>
  
  <p>Line from <code>urls.py</code>:</p>
  
  <pre><code>url(r'^review_form/', ReviewWizard.as_view([AnswerForm, AnswerForm]), name='review_form'),
  </code></pre>
  
  <p>This is my form:</p>
  
  <pre><code>class AnswerForm(forms.Form):
      answer = forms.CharField(required=True)
  
      def __init__(self, *args, **kwargs):
          self.request = kwargs.pop('request')
          self.question = None
          self.setup()
          super(AnswerForm, self).__init__(*args, **kwargs)
          self.fields['answer'].label = self.question.question
  
      def setup(self):
          if "question" in self.request.session:
              self.question = Question.objects.get(id=self.request.session["question"])
          else:
              self.question = get_random_question()
              self.request.session["question"] = self.question.id
  
      def save(self):
          del self.request.session["question"]
          Answer.objects.create(
              question=self.question,
              author=self.request.user,
              answer=self.cleaned_data['answer']
          )
  </code></pre>
  
  <p>This is my Wizard Class in <code>views.py</code> (I copied it from elsewhere):</p>
  
  <pre><code>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})
  </code></pre>