title: Django Login Incorrect password showing for correct password
body: <p>I am making a login form and using Django 1.8 Python 3.5 </p>
  
  <p>But I am getting Incorrect password for valid username and password what should I do ?</p>
  
  <p>I have made a simple login form but am not able to figure out the error , please help</p>
  
  <p>This is my <code>login/forms.py</code></p>
  
  <pre><code>from django import forms
  from mainpage.models import User
  from django.contrib.auth import (
      authenticate,
      login,
      logout,
      get_user_model,
  )
  
  class UserLoginForm(forms.Form):
          username=forms.CharField(max_length=40)
          password=forms.CharField(max_length=40,widget=forms.PasswordInput)
  
  
          def clean(self,*args,**kwargs):
              username=self.cleaned_data.get("username")
              password=self.cleaned_data.get("password")
              user_qs = User.objects.filter(username=username)
              if user_qs.count() == 0:
                  raise forms.ValidationError("The user does not exist")
              else:
                  if username and password:
                       user = authenticate(username=username, password=password)
  
                       if not user:
                          raise forms.ValidationError("Incorrect password")
                       if not user.is_active:
                           raise forms.ValidationError("This user is no longer active")
              return super(UserLoginForm,self).clean(*args,**kwargs)
  </code></pre>
  
  <p>This is my <code>login/views.py</code></p>
  
  <pre><code>from django.shortcuts import render,redirect
  from .forms import UserLoginForm
  from django.contrib.auth import login as auth_loginwa
  from django.contrib.auth import (
  
      authenticate,
      logout,
      get_user_model,
  
  )
  def login_view(request):
      form1=UserLoginForm(request.POST or None)
      print(request.user.is_authenticated())
      if form1.is_valid():
          username=form1.cleaned_data.get("username")
          password=form1.cleaned_data.get("password")
          user=authenticate(username=username,password=password)
          auth_loginwa(request,user)
          if(request.user.is_authenticated()):
              return redirect("home2")
      context= {
          "form1": form1,
      }
      return render(request, "login.html",context)
  </code></pre>
  
  <p>This is my <code>mainpage/models.py</code></p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractUser
  
  class User(AbstractUser):
      bio = models.TextField(max_length=500, blank=True)
      location = models.CharField(max_length=30, blank=True)
      birth_date = models.DateField(null=True, blank=True)
  </code></pre>
  
  <p><strong>As asked in comments</strong></p>
  
  <p>this is  my <strong>mainpage/admin.py</strong></p>
  
  <pre><code>from django.contrib import admin
  from .models import User
  admin.site.register(User)
  </code></pre>
  
  <p>these are images for my different users</p>
  
  <p>superuser vaibhav2(created using command python manage.py create superuser)<a href="https://imgur.com/hAwt5qy" rel="nofollow noreferrer">Has encrypted password</a> also the login of it get s successful</p>
  
  <p>user asd create manually <a href="https://imgur.com/GC1db2i" rel="nofollow noreferrer">(No encrypted password see image)</a></p>
  
  <p><a href="https://imgur.com/EOewk41" rel="nofollow noreferrer">https://imgur.com/EOewk41</a></p>