﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28706	Allow easier reuse of AuthenticationForm invalid_login ValidationError	Jon Dufresne	nobody	"The `AuthenticationForm` contains the [https://github.com/django/django/blob/4d60261b2a77460b4c127c3d832518b95e11a0ac/django/contrib/auth/forms.py#L190-L205 snippet in the clean method]:

{{{
    def clean(self):
        username = self.cleaned_data.get('username')
        password = self.cleaned_data.get('password')

        if ...:
            ...
            if ... is None:
                raise forms.ValidationError(
                    self.error_messages['invalid_login'],
                    code='invalid_login',
                    params={'username': self.username_field.verbose_name},
                )
        ...
}}}

In my project, I have overridden `AuthenticationForm` with customizations. Among these customizations, I have other reasons for raising an `invalid_login`. Rather than copy round the:

{{{
                raise forms.ValidationError(
                    self.error_messages['invalid_login'],
                    code='invalid_login',
                    params={'username': self.username_field.verbose_name},
                )
}}}

I suggest the form wrap this in a small function for reuse.

I'm not sure if this requires documentation or can remain an internal implementation detail. I'm happy to also add documentation if it is a good idea."	Cleanup/optimization	closed	contrib.auth	dev	Normal	fixed			Ready for checkin	1	0	0	0	0	0
