title: How can I get the Django auth SetPasswordForm to display errors?
body: <p>I am using Django's <em>SetPasswordForm</em> to allow the user to reset their own password.They will have been sent an email and clicked on a link which directs them to: <em>/users/new-password/uid/token</em></p>
  <p><strong>urls.py</strong></p>
  <pre><code>path('new-password/&lt;uidb64&gt;/&lt;str:token&gt;/', views.NewPassword.as_view(), name='new-password'),
  path('new-password-post/', views.NewPasswordPost.as_view(), name='new-password-post'),
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>class NewPassword(View):
      url = 'users/new_password.html'
  
      def get(self, request, uidb64, token):
          try:
              uid = force_text(urlsafe_base64_decode(uidb64))
              user = User.objects.get(pk=uid)
          except (TypeError, ValueError, OverflowError, User.DoesNotExist):
              user = None
  
          if user is None or not account_activation_token.check_token(user, token):
              text = 'Your password cannot be reset. Please contact support.'
              messages.error(request, text)
              return HttpResponseRedirect(reverse('account'))
  
          password_form = SetPasswordForm(user=user)
          context = {
              'password_form': password_form,
              'uidb64': uidb64,
              'token': token,
          }
          return render(request, 'users/new_password.html', context)
  
  
  class NewPasswordPost(View):
      url = 'users/new_password.html'
  
      def post(self, request):
          uidb64 = request.POST['uidb64']
          token = request.POST['token']
          uid = force_text(urlsafe_base64_decode(uidb64))
          user = User.objects.get(pk=uid)
          password_form = SetPasswordForm(request.POST)
          if not password_form.is_valid():
              for field in password_form.fields.items():
                  print(field, field[1].error_messages)
              context = {
                  'password_form': password_form,
                  'uidb64': uidb64,
                  'token': token,
                  }
              return render(request, self.url, context)
          messages.success(request, 'Your password has been reset. You may now sign in.')
          password_form.save()
          return render(request, reverse('login'), context)
  </code></pre>
  <p><strong>new_password.html</strong></p>
  <pre><code>&lt;form method=&quot;post&quot; action=&quot;{% url 'new-password' %}&quot;&gt;
  {% csrf_token %}
      &lt;h1&gt;Set New Password&lt;/h1&gt;
      &lt;table&gt;
          {% for field in password_form %}
              &lt;tr&gt;
                  &lt;td&gt;{{ field.label_tag }}&lt;/td&gt;
                  &lt;td&gt;{{ field }}&lt;/td&gt;
                  {% if field.errors %}
                      {% for error in field.errors %}
                          &lt;td style=&quot;color: red&quot;&gt;{{ error }}&lt;/td&gt;
                      {% endfor %}
                  {% endif %}
              &lt;/tr&gt;
          {% endfor %}
      &lt;/table&gt;
      &lt;button type=&quot;submit&quot; class=&quot;btn btn-success&quot;&gt;Submit&lt;/button&gt;
      &lt;input type=&quot;hidden&quot; id=&quot;uidb64&quot; name=&quot;uidb64&quot; value=&quot;{{ uidb64 }}&quot;&gt;
      &lt;input type=&quot;hidden&quot; id=&quot;token&quot; name=&quot;token&quot; value=&quot;{{ token }}&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>The print statements in <em>NewPasswordPost</em> give:</p>
  <blockquote>
  <p>('new_password1', &lt;django.forms.fields.CharField object at 0x7f4a53d94940&gt;) {'required': 'This field is required.'}</p>
  </blockquote>
  <blockquote>
  <p>('new_password2', &lt;django.forms.fields.CharField object at 0x7f4a53d94130&gt;) {'required': 'This field is required.'}</p>
  </blockquote>
  <p>but I do not see any errors on the <em>SetPasswordForm</em> e.g. passwords do not match</p>