title: Django - using generic login view not working
body: <p>EDIT: the view now does log me in when I enter a correct username and password, but doesn't return any errors when I enter incorrect username and passwords.
  I am using the generic login view provided by Django. This is my login.html template:</p>
  
  <pre><code>&lt;body&gt;
      &lt;h1&gt;User Login&lt;/h1&gt;
  
      {% if form.has_errors %}
          &lt;p&gt;Your username and password did not match. 
          Please try again.&lt;/p&gt;
      {% else %}
          &lt;form method="post" action=" . "&gt;{% csrf_token %}
              &lt;p&gt;&lt;label for="id_username"&gt;Username:&lt;/label&gt;
              {{ form.username }}&lt;/p&gt;
  
              &lt;p&gt;&lt;label for="id_password"&gt;Password:&lt;/label&gt;
              {{ form.password }}&lt;/p&gt;
  
              &lt;input type="hidden" name="next" value="/" /&gt;
              &lt;input type="submit" value="login" /&gt;
          &lt;/form&gt;
      {% endif %}
  &lt;/body&gt;
  </code></pre>
  
  <p>Now, I am following the tutorial in the book called "Pact Publishing. Learning Website Development with Django". The view never returns </p>
  
  <pre><code>form.has_errors
  </code></pre>
  
  <p>even though I purposely submit an incorrect username and password. It just keeps returning me to the same page after I click submit. Also, according to the HTML book I read, it said that the 'action' attribute in the form is the URL of the page on the server that will retrieve the information. Is that why it isn't working? Because my</p>
  
  <pre><code>action=" . "
  </code></pre>
  
  <p>?</p>
  
  <p>EDIT: the view is the generic login view:</p>
  
  <pre><code>@sensitive_post_parameters()
  @csrf_protect
  @never_cache
  def login(request, template_name='registration/login.html',
            redirect_field_name=REDIRECT_FIELD_NAME,
            authentication_form=AuthenticationForm,
            current_app=None, extra_context=None):
      """
      Displays the login form and handles the login action.
      """
      redirect_to = request.REQUEST.get(redirect_field_name, '')
      if request.method == "POST":
          form = authentication_form(data=request.POST)
          if form.is_valid():
  
              # Ensure the user-originating redirection url is safe.
              if not is_safe_url(url=redirect_to, host=request.get_host()):
                  redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)
  
              # Okay, security check complete. Log the user in.
              auth_login(request, form.get_user())
  
              if request.session.test_cookie_worked():
                  request.session.delete_test_cookie()
  
              return HttpResponseRedirect(redirect_to)
      else:
          form = authentication_form(request)
  
      request.session.set_test_cookie()
  
      current_site = get_current_site(request)
  
      context = {
          'form': form,
          redirect_field_name: redirect_to,
          'site': current_site,
          'site_name': current_site.name,
      }
      if extra_context is not None:
         context.update(extra_context)
      return TemplateResponse(request, template_name, context,
                              current_app=current_app)
  </code></pre>
  
  <p>and my urls.py is just</p>
  
  <pre><code>url(r'^$', main_page),
  url(r'^user/(\w+)/$', user_page), 
  url(r'^login/$', login),
  </code></pre>