Reputation: 388
I currently use this alternative AuthenticationForm
:
class AuthenticationForm(AuthenticationForm):
username = forms.CharField(widget=forms.HiddenInput(), initial="members")
def confirm_login_allowed(self, user):
pass
def __init__(self, *args, **kwargs):
super(AuthenticationForm, self).__init__(*args, **kwargs)
self.fields['password'].error_messages = {'incomplete': 'Please enter a valid password.'}
for field in self.fields.values():
field.error_messages = {'required':'T {fieldname} is required'.format(
fieldname=field.label)}
Some of this code is useless, but I'm trying to change the error message for when the user enters an incorrect password. Currently, django supplies the error message: Please enter a correct username and password. Note that both fields may be case-sensitive.
, though I would like it to be Please enter the correct password
.
This is an edge case, I suppose.
Thanks for any help.
Upvotes: 1
Views: 946
Reputation: 59
go to the AuthenticationForm class then edit the error_messages...
---THIS IS THE IMAGE--- AuthenticationForm ---THIS IS THE IMAGE---
Upvotes: 0
Reputation: 118
can you try it?
class AuthenticationForm(AuthenticationForm):
username = forms.CharField(widget=forms.HiddenInput(), initial="members")
password = forms.CharField(error_messages={'incomplete': 'Please enter a valid password.'})
Upvotes: 1