Opened 7 years ago
Closed 7 years ago
#30163 closed Bug (invalid)
UserCreationForm's error_messages for 'password1' and 'password2' can't be overidden by form's Meta.error_essages
| Reported by: | Oskar Haller | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.auth | Version: | 2.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
class UserRegisterForm(UserCreationForm):
"""
Form class to register a new user
"""
class Meta:
#https://docs.djangoproject.com/en/2.1/topics/forms/modelforms/#modelforms-overriding-default-fields
model = User
fields = (...'password1', 'password2')
error_messages = {
'password1': {
'required': _('Please enter a password.')
},
'password2': {
'required': _('Please enter a password.')
}
}
Instead of 'Please enter a password' I get 'This field is required.'
For all other fields the overrriding works fine
Change History (3)
comment:1 by , 7 years ago
| Type: | Uncategorized → Bug |
|---|
comment:2 by , 7 years ago
| Description: | modified (diff) |
|---|---|
| Summary: | error_messages password1 'required' can not be overwritten → error_messages 'password1' 'required' can not be overidden |
comment:3 by , 7 years ago
| Component: | Uncategorized → contrib.auth |
|---|---|
| Resolution: | → invalid |
| Status: | new → closed |
| Summary: | error_messages 'password1' 'required' can not be overidden → UserCreationForm's error_messages for 'password1' and 'password2' can't be overidden by form's Meta.error_essages |
Note:
See TracTickets
for help on using tickets.
error_messagesis a dictionary of model field names mapped to a dictionary of error messages. It doesn't work for non-model fields likepassword1andpassword2.