title: Django "login() takes exactly 1 argument (2 given)" error
body: <p>I'm trying to store the user's ID in the session using django.contrib.auth.login . But it is not working not as expected.</p>
  
  <p>I'm getting error <strong>login() takes exactly 1 argument (2 given)</strong></p>
  
  <p>With login(user) I'm getting <strong>AttributeError at /login/ User' object has no attribute 'method'</strong></p>
  
  <p>I'm using slightly modifyed example form <a href="http://docs.djangoproject.com/en/dev/topics/auth/#how-to-log-a-user-in" rel="noreferrer">http://docs.djangoproject.com/en/dev/topics/auth/</a> :</p>
  
  <pre><code>from django.shortcuts import render_to_response
  from django.contrib.auth import authenticate, login
  
  def login(request):
      msg = []
      if request.method == 'POST':
          username = request.POST['u']
          password = request.POST['p']
          user = authenticate(username=username, password=password)
          if user is not None:
              if user.is_active:
                  login(request, user)
                  msg.append("login successful")
              else:
                  msg.append("disabled account")
          else:
              msg.append("invalid login")
      return render_to_response('login.html', {'errors': msg})
  </code></pre>
  
  <p>there's nothing special about login.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form action="/login/" method="post"&gt;
          Login:&amp;nbsp; &lt;input type="text" name="u"&gt;
      &lt;br/&gt;
          Password:&amp;nbsp; &lt;input type="password" name="p"&gt;
          &lt;input type="submit" value="Login"&gt;
      &lt;/form&gt;
      {% if errors %}
          &lt;ul&gt;
              {% for error in errors %}
              &lt;li&gt;{{ error }}&lt;/li&gt;
              {% endfor %}
          &lt;/ul&gt;
      {% endif %}
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Does anybody have idea how to make login() work.</p>