{{{
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/28706>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/9231 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/28706#comment:1>
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Ready for checkin
Comment:
Looks good, I don't think documentation is required here.
--
Ticket URL: <https://code.djangoproject.com/ticket/28706#comment:2>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"6ed347d8518e23d7e453bdb21f7fa59ce2c4a885" 6ed347d]:
{{{
#!CommitTicketReference repository=""
revision="6ed347d8518e23d7e453bdb21f7fa59ce2c4a885"
Fixed #28706 -- Moved AuthenticationFormn invalid login ValidationError to
a method for reuse.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28706#comment:3>