title: Showing errors with LoginView in Django
body: <p>I have a problem with displaying errors on the template for login page. I am using the Login built in view and I made a custom form which inherits from AuthenticationForm and I tried to override the clean() method but if the username or password is not correct is not displaying any ValidationErorr message. Any help?
  I created a custom view because I need to inherit from a custom mixin for some restrictions.
  my view:</p>
  <pre><code>class UserLoginView(IsAuthenticatedMixin, LoginView):
      template_name = 'home/auth/login.html'
      authentication_form = UserLoginForm
  </code></pre>
  <p>my form:</p>
  <pre><code>class UserLoginForm(AuthenticationForm):
      username = forms.CharField(widget=forms.TextInput())
      password = forms.CharField(widget=forms.PasswordInput())
  
      def clean(self):
          cleaned_data = super().clean()
          username = self.cleaned_data.get('username')
          password = self.cleaned_data.get('password')
          if username is not None and password:
              login = authenticate(self.request, username=username, password=password)
              if login is None:
                  raise ValidationError('The username or password are incorrect')
          return self.cleaned_data
  </code></pre>
  <p>url:</p>
  <pre><code>path('auth/login/', UserLoginView.as_view(), name='login'),
  </code></pre>
  <p>my template:</p>
  <pre><code>{% extends 'home/auth/base.html' %}
  {% load widget_tweaks %}
  {% block content %}
      &lt;!-- Outer Row --&gt;
      &lt;div class=&quot;row justify-content-center&quot;&gt;
  
        &lt;div class=&quot;col-xl-10 col-lg-12 col-md-9&quot;&gt;
  
          &lt;div class=&quot;card o-hidden border-0 shadow-lg my-5&quot;&gt;
            &lt;div class=&quot;card-body p-0&quot;&gt;
              &lt;div class=&quot;row&quot;&gt;
                &lt;div class=&quot;col-lg-6 d-none d-lg-block bg-login-image&quot;&gt;&lt;/div&gt;
                &lt;div class=&quot;col-lg-6&quot;&gt;
                  &lt;div class=&quot;p-5&quot;&gt;
                    &lt;div class=&quot;text-center&quot;&gt;
                      &lt;h1 class=&quot;h4 text-gray-900 mb-4&quot;&gt;Welcome Back!&lt;/h1&gt;
                    &lt;/div&gt;
                    &lt;form class=&quot;user&quot; method=&quot;POST&quot;&gt;
                      {% csrf_token %}
                      &lt;div class=&quot;form-group&quot;&gt;
                        {% for error in form.non_field.errors %}
                        &lt;div class=&quot;invalid-feedback&quot;&gt;
                          {{ error }}
                        &lt;/div&gt;
                        {% endfor %}
                        {% render_field form.username class=&quot;form-control form-control-user&quot; id=&quot;exampleInputEmail&quot; aria-describedby=&quot;emailHelp&quot; placeholder=&quot;Enter Username...&quot; %}
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                        {% render_field form.password class=&quot;form-control form-control-user&quot; id=&quot;exampleInputPassword&quot; placeholder=&quot;Password&quot; %}
                      &lt;/div&gt;
                      &lt;div class=&quot;form-group&quot;&gt;
                        &lt;div class=&quot;custom-control custom-checkbox small&quot;&gt;
                          &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; id=&quot;customCheck&quot;&gt;
                          &lt;label class=&quot;custom-control-label&quot; for=&quot;customCheck&quot;&gt;Remember Me&lt;/label&gt;
                        &lt;/div&gt;
                      &lt;/div&gt;
                      &lt;input type=&quot;submit&quot; name=&quot;Login&quot; class=&quot;btn btn-primary btn-user btn-block&quot; value=&quot;Login&quot;&gt;
                      &lt;hr&gt;
                      &lt;a href=&quot;index.html&quot; class=&quot;btn btn-google btn-user btn-block&quot;&gt;
                        &lt;i class=&quot;fab fa-google fa-fw&quot;&gt;&lt;/i&gt; Login with Google
                      &lt;/a&gt;
                      &lt;a href=&quot;index.html&quot; class=&quot;btn btn-facebook btn-user btn-block&quot;&gt;
                        &lt;i class=&quot;fab fa-facebook-f fa-fw&quot;&gt;&lt;/i&gt; Login with Facebook
                      &lt;/a&gt;
                    &lt;/form&gt;
                    &lt;hr&gt;
                    &lt;div class=&quot;text-center&quot;&gt;
                      &lt;a class=&quot;small&quot; href=&quot;forgot-password.html&quot;&gt;Forgot Password?&lt;/a&gt;
                    &lt;/div&gt;
                    &lt;div class=&quot;text-center&quot;&gt;
                      &lt;a class=&quot;small&quot; href=&quot;{% url 'register' %}&quot;&gt;Create an Account!&lt;/a&gt;
                    &lt;/div&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
          &lt;/div&gt;
  
        &lt;/div&gt;
  
      &lt;/div&gt;
  {% endblock %}
  
  </code></pre>