In my application directory, I subclassed PasswordChangeForm and SetPasswordForm. Then I added my custom validation code, which is just making sure the password is at least eight characters long:
from django import formsfrom django.contrib.auth.forms import PasswordChangeForm, SetPasswordFormfrom django.utils.translation import ugettext_lazy as _class MyPasswordChangeForm(PasswordChangeForm):new_password1 = forms.CharField(label=_("New password"),min_length=8,widget=forms.PasswordInput)new_password2 = forms.CharField(label=_("New password confirmation"),min_length=8,widget=forms.PasswordInput)class MySetPasswordForm(SetPasswordForm):new_password1 = forms.CharField(label=_("New password"),min_length=8,widget=forms.PasswordInput)new_password2 = forms.CharField(label=_("New password confirmation"),min_length=8,widget=forms.PasswordInput)
Then I imported my new classes into registration\auth_urls.py and added my new classes as parameters to password/change and password/reset/confirm/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/:
url(r'^password/change/$',
auth_views.password_change,{'password_change_form': MyPasswordChangeForm},'auth_password_change'),
and
auth_views.password_reset_confirm,
{'set_password_form': MySetPasswordForm},
And that's it.
Spork
-- 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+unsubscribe@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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment