title: Curious about get_form_kwargs in FormView
body: <p>I was having trouble with FormView recently and found that the way to go about doing it was to use get_form_kwargs.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class InternalResetPasswordView(FormView):
  
  template_name = 'reset_password.html'
  form_class = forms.InternalPasswordResetForm
  
  # success_message = "Password was reset successfully"
  
  # To get request object
  # http://notesondjango.wordpress.com/2012/12/18/modelform-formview-and-the-request-object/
  # https://stackoverflow.com/questions/13383381/show-message-after-password-change
  # http://pydanny.com/simple-django-email-form-using-cbv.html
  # http://bubuzzz.wordpress.com/2012/05/01/class-based-generic-views-in-django-a-simple-sample/
  def get_form_kwargs(self):
      kwargs = super(InternalResetPasswordView, self).get_form_kwargs()
      kwargs['user'] = self.request.user
      return kwargs
  
  def get_success_url(self):
      return reverse('user-detail', kwargs={'pk': self.request.user.id})
  
  @method_decorator(login_required)
  def dispatch(self, *args, **kwargs):
      return super(InternalResetPasswordView, self).dispatch(*args, **kwargs)   
  
  '''
  def get_context_data(self, **kwargs):
  
      context = super(InternalResetPasswordView, self).get_context_data(**kwargs)
      context['InternalPasswordResetForm'] = context.get('form')
  
      return context
  
  
  def get_form_kwargs(self):
      kwargs = super(InternalResetPasswordView, self).get_form_kwargs()
      kwargs['request'] = self.request
      return kwargs
  
  '''
  # self.request.user method obtained from
  # https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-editing/
  def form_valid(self, form):
      current_password = form.cleaned_data['old_password']
      new_password =  form.cleaned_data['new_password1']
      confirm_new_password = form.cleaned_data['new_password2']
      user = self.request.user
      if user.check_password(current_password) and new_password == confirm_new_password:
          user.set_password(new_password)
          user.save()
          # form.valid() redirects to get_success_url
      return super(InternalResetPasswordView, self).form_valid(form)
  </code></pre>
  
  <p>After looking at <a href="https://stackoverflow.com/questions/12064000/django-accessing-request-in-forms-py-clean-function/12064048#12064048">this post</a>, I still don't understand why get_form_kwargs has to be used and why using self.request instead of self.request.user in this case gives <code>__init__() got an unexpected keyword argument 'request'</code>. </p>
  
  <p>Could someone explain this to me?</p>
  
  <p>Thanks for all the help :)</p>