Hi Larry, You could configure the routes in the urls.py, take the create user route and plug in your CustomPasswordForm... ... customization example of the userena urls for the normal frontend
... url(r'^(?P<username>[\.\w]+)/password/$', userena_views.password_change, {"pass_form": PasswordChangeForm}, name = 'userena_password_change'), ... cheers Frank Am Freitag, 10. April 2015 21:15:17 UTC+2 schrieb larry....@gmail.com: > > I am trying to add custom password validation to the create user and > change password admin forms. I did not see anything in the django docs > about how to do this. From what I read on stackoverflow and other > sites it seems I have to write a validator and then someone hook it > into the add and change forms. > > Here's what I have now in my apps admin.py: > > def validate_password_strength(value): > """Validates that a password is as least 10 characters long and has at > least > 2 digits and 1 Upper case letter. > """ > min_length = 10 > > if len(value) < min_length: > raise ValidationError(_('Password must be at least {0} characters > ' > 'long.').format(min_length)) > > # check for 2 digits > if sum(c.isdigit() for c in value) < 2: > raise ValidationError(_('Password must container at least 2 > digits.')) > > # check for uppercase letter > if not any(c.isupper() for c in value): > raise ValidationError(_('Password must container at least 1 > uppercase letter.')) > > class MySetPasswordForm(SetPasswordForm): > def __init__(self, *args, **kwargs): > super(MySetPasswordForm, self).__init__(*args, **kwargs) > > self.fields['password1'].validators.append(validate_password_strength) > > But what I can't figure out is how do I get MySetPasswordForm to be > used. Can anyone help me with this. If i am way off base, can someone > point me in the right direction. Thanks! > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3d2a353a-48f6-488e-ad27-4b592b083787%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.