Enforcing a min length in Django password -
Enforcing a min length in Django password -
i using django.contrib.auth.views.password_password_reset_confirm
alter user's password. how urls look:
from django.contrib.auth import views auth_views url(r'^password/reset/confirm/(?p<uidb36>[0-9a-za-z]+)-(?p<token>.+)/$', redirect_if_loggedin(auth_views.password_reset_confirm), name='auth_password_reset_confirm'),
currently, doing straight django trunk -
# django.contrib.auth.views def clean_new_password2(self): password1 = self.cleaned_data.get('new_password1') password2 = self.cleaned_data.get('new_password2') if password1 , password2: if len(password1) < 8: raise forms.validationerror(_("password must @ to the lowest degree 8 chars.")) if password1 != password2: raise forms.validationerror(_("the 2 password fields didn't match.")) homecoming password2
surely there must improve way.
if understand correctly, you're modifying django code? because that's can not way it.
what form use? seems indeed built-in passwordchangeform won't allow set min_length.
maybe utilize password_change view , set own password_change_form, inherit basic passwordchangeform apply additional cleaning.
django django-forms
Comments
Post a Comment