title: Django problem with creating user then logging them in
body: <p>Hello all you helpful people out there (and goodbye none-helpful people :D ). I'm trying to create a user in django (1.2.4) and then log them in after saving them. My problem is I'm getting NotImplementedError and looking at the traceback it's being raised by django.contrib.auth.models.AnonymousUser . Here is part of my view code:</p>
  
  <pre><code>def signup(request):
      if request.method == 'POST': # If the form has been submitted...
          p = request.POST
          if not request.user.is_authenticated():
              form = UserForm(request.POST) # A form bound to the POST data
              if form.is_valid(): # All validation rules pass
                  # Process the data in form.cleaned_data
                  # ...
                  form.save()
                  user=authenticate(username=p['username'],password=p['password'])
                  login(request,user)
                  return HttpResponseRedirect('/') # Redirect after POST
  </code></pre>
  
  <p>So it looks to me that It's trying to log in an anymouse user instead of the one I'm authenticating, how can I overcome this?</p>
  
  <p>Thanks
  P.S. The users are being created in the database, it just won't log them in using this code.</p>
  
  <p>Traceback:</p>
  
  <blockquote>
    <p>Environment:<br>
         Request Method: POST<br>
         Request URL: <a href="http://localhost:8000/signup/" rel="noreferrer">http://localhost:8000/signup/</a><br>
         Django Version: 1.2.4<br>
         Python Version: 2.6.1<br>
         Installed Applications:<br>
         ['django.contrib.auth',<br>
          'django.contrib.contenttypes',<br>
          'django.contrib.sessions',<br>
          'django.contrib.sites',<br>
          'django.contrib.messages',<br>
          'django.contrib.admin',<br>
          'django.contrib.admindocs',<br>
          'django_extensions',<br>
          'REDACTED_APPs',
         Installed Middleware:
         ('django.middleware.common.CommonMiddleware',
          'django.middleware.locale.LocaleMiddleware',
          'django.contrib.sessions.middleware.SessionMiddleware',
          'django.contrib.auth.middleware.AuthenticationMiddleware',
          'django.contrib.messages.middleware.MessageMiddleware',
          'django.contrib.sessions.middleware.SessionMiddleware')</p>
  </blockquote>
  
  <pre><code> Traceback:    
   File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response    
     100.                     response = callback(request, *callback_args, **callback_kwargs)    
   File "REDACTED/views.py" in signup    
     19.                 login(request,user)    
   File "/Library/Python/2.6/site-packages/django/contrib/auth/__init__.py" in login    
     71.     user.save()    
   File "/Library/Python/2.6/site-packages/django/contrib/auth/models.py" in save    
     430.         raise NotImplementedError    
  
   Exception Type: NotImplementedError at /signup/    
   Exception Value:
  </code></pre>