title: Django's authentication form is always not valid
body: <p>I was trying to implement a basic login system using Django with a custom user using the AbstractUser class.
  Here is my models.py:</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractUser
  
  class Stock(models.Model):
      stock_name = models.CharField(max_length=10)
      stock_price = models.FloatField()
  
      def __str__(self):
          return self.stock_name
  
  class CustomUser(AbstractUser):
      stocks = models.ManyToManyField(Stock)
  
      def __str__(self):
          return self.username
  </code></pre>
  
  <p>My forms.py:</p>
  
  <pre><code>from .models import CustomUser,Stock
  from django.contrib.auth.forms import AuthenticationForm
  
  class loginform(AuthenticationForm):
      class Meta:
          model = CustomUser
          fields = ('username', 'password')
  </code></pre>
  
  <p>My views.py:</p>
  
  <pre><code>def successful_login(request, pk):
      user = get_object_or_404(CustomUser, pk=pk)
      return render(request, '../templates/stock_portfolio.html', {'user':user})
  
  def loginview(request):
      err=0
      if request.method=="POST":
          form = loginform(request.POST)
          pdb.set_trace()
          if form.is_valid():
              username = form.cleaned_data['username']
              password = form.cleaned_data['password']
              user = authenticate(username=username, password=password)
              if user is not None:
                  pdb.set_trace()
                  login(request, user)
                  pk = user.id
                  pdb.set_trace()
                  return redirect('successful_login', pk=pk)
          else:
              err=1
              return render(request,'../templates/login.html',{'response':err,'form':form})
      else:
          form = loginform()
      return render(request, '../templates/login.html',{'form':form})
  </code></pre>
  
  <p>While logging using pdb here is what I am getting for the form.</p>
  
  <pre><code>&lt;loginform bound=False, valid=Unknown, fields=(username;password)&gt;
  </code></pre>
  
  <p>How do I proceed now?</p>