title: Django authentication failing with a 403 with no detailed message
body: <p>I have something pretty simple which I've thrown together. I have a little form like this:</p>
  
  <pre><code>&lt;form id="loginForm" action&gt;
      &lt;input name="email_address" type="text" placeholder="Email"&gt;
      &lt;input name="password" type="password"&gt;
      &lt;a id="loginButton"&gt;Login&lt;/a&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My JavaScript does the following:</p>
  
  <pre><code>$("#loginButton").click(function(){
      $.post("/login/",$("#loginForm").serialize(), function(data) {
          console.log("login.");
      });
  });
  </code></pre>
  
  <p>I've written a custom Django authentication backend:</p>
  
  <pre><code>from my.custom.project.models import User
  
  class MyBackend:
  
      def authenticate(self, email_address=None, password=None):
          print "Trying to auth"
          try:
              return User.objects.get(email_address=email_address, password=password)
          except User.DoesNotExist:
              return None
  
      def get_user(self, user_id):
          try:
              return User.objects.get(pk=user_id)
          except User.DoesNotExist:
              return None
  </code></pre>
  
  <p>I have this configured in my <code>settings.py</code> like so:</p>
  
  <pre><code>AUTHENTICATION_BACKENDS = (
      "my.custom.project.auth.MyBackend",
  )
  </code></pre>
  
  <p>In my actual view for the <code>/login/</code> path, here's what I have:</p>
  
  <pre><code>from django.contrib import auth
  
  def login(request):
      print "Trying to auth..."
      email_address = request.POST['email_address']
      password = request.POST['password']
  
      user = auth.authenticate(email_address=email_address, password=password)
  
      if user != None:
          auth.login(request, user)
  
      direct_to_template(request, "my/login/template.json")
  </code></pre>
  
  <p>Here's my URL map:</p>
  
  <pre><code>from django.conf.urls.defaults import * 
  from django.contrib import admin
  from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  
  admin.autodiscover()
  
  urlpatterns = staticfiles_urlpatterns
  
  urlpatterns += patterns('',
      (r'^admin/', include(admin.site.urls)),
      (r'^admin/doc', include('django.contrib.admindocs.urls')),
  )
  
  urlpatterns += patterns('my.project.views',
      (r'^$', 'root'),
      (r'^login/?$', 'login'),
      (r'^logout/?$', 'logout'),
  )
  </code></pre>
  
  <p>Can anyone see what I'm doing wrong here? All I get in the Django server output is:</p>
  
  <pre><code>[16/Sep/2011 20:17:47] "POST /login/ HTTP/1.1" 403 2326
  </code></pre>
  
  <p>Am I taking crazy pills? What did I overlook? </p>