Django AuthenticationForm and non field errors

Here’s a quick tip for the built in Django AuthenticationForm in django.contrib.auth.forms: use the non_field_errors method when trying to display the incorrect user/pass error. The error is raised in the general clean method and is not bound to any field, so using form.errors doesn’t give you the error message itself.

{{ form.non_field_errors }}

Leave a Reply

Your email address will not be published. Required fields are marked *