django - override password_validation messages -
i use usercreationform create new users.
from django.contrib.auth.forms import usercreationform class registrationform(usercreationform): class meta: model = user fields = ['username', 'first_name', 'last_name', 'email', 'is_active']
usercreationform
automatically adds 2 fields (password1 , password2). if password short raises error, telling that. or if simple or common. done via django.contrib.auth.password_validation
.
i wonder if can override messages of these errors.
right source code password validation is:
def validate(self, password, user=none): if len(password) < self.min_length: raise validationerror( ungettext( "this password short. must contain @ least %(min_length)d character.", "this password short. must contain @ least %(min_length)d characters.", self.min_length ), code='password_too_short', params={'min_length': self.min_length}, )
but when try use code in form definition override error message label changes, error_messages remain same:
password1 = forms.charfield(label='new label', error_messages={'password_too_short': 'my error message short passwords'})
what doing wrong?
Comments
Post a Comment