title: AttributeError: 'NoneType' object has no attribute 'check_password' error in django allauth
body: <p>I am using django all auth for my login and signup views and templates, but i also want to implement the change password functionality, so by default it has a template <code>password_change.html</code> that we can use, but i want a custom design, and that to dont want to get refreshed the page by using builtin <code>allauth</code> password change view, so decided to use only the <code>ChangePasswordForm</code> form of allauth by importing it in my views.</p>
  
  <p>I am posting a request using ajax to a <code>url(view)</code> and returning a <code>Json Response</code>, so that i can use the response in jquery/ajax in my custom template.</p>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>from allauth.account.forms import ChangePasswordForm
  
  @login_required
  def change_password(request):
      form =  ChangePasswordForm(data=request.POST)
      if form.is_valid():
          form.save()
          result = {'status':'done'}
      else:
          result = {'status':'undone', 'form_errors':form.errors}
      json_data = json.dumps(result)
      return HttpResponse(json_data, 'application/json')
  </code></pre>
  
  <p><strong>templates.html</strong></p>
  
  <pre><code>$('.form').click(function(){
     $.ajax({
                        type: "POST",
                                url: '/change_password/',
                                data: form_data,
                                success: function(response)
                                  {
                                      if(response.status === 'done')
                                          console.log('great====&gt;');
                                      ......
                                      .....   
                          }
                     });   
   });    
  </code></pre>
  
  <p>and i am rendering the fields in the template individually like <code>form.oldpassword, form.newpassword, ....</code> also with the errors.</p>
  
  <p>So when i submit the form without any data i am getting the correct errors messages that <code>this fields are required</code>, but when i entered just only one field <code>oldpassword</code> and submitted the form i am getting the below error</p>
  
  <pre><code>  File "/home/user/Envs/proj/local/lib/python2.7/site-packages/django/forms/forms.py", line 290, in _clean_fields
      value = getattr(self, 'clean_%s' % name)()
    File "/home/user/Envs/proj/local/lib/python2.7/site-packages/allauth/account/forms.py", line 334, in clean_oldpassword
      if not self.user.check_password(self.cleaned_data.get("oldpassword")):
  AttributeError: 'NoneType' object has no attribute 'check_password'
  </code></pre>
  
  <p>So after debugging i checked the value of <code>self.user</code> in clean_oldpassword validation method under ChangePasswordForm class in allauth forms.py is printing <code>None</code>, so y actually i am facing the above error ?</p>
  
  <p>Why actually the user was none, when using the django allauth ChangePasswordForm ?</p>
  
  <p>Am i doing anything wrong when using the <code>ChangePasswordForm Form</code> ?</p>