我目前正在使用django.contrib.auth.views.password_password_reset_confirm
来更改用户的密码。这是我的 URL 看起来的样子:
from django.contrib.auth import views as 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'),
目前,我直接在Django主干上进行开发 -
# 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 and password2:
if len(password1) < 8:
raise forms.ValidationError(_("Password must be at least 8 chars."))
if password1 != password2:
raise forms.ValidationError(_("The two password fields didn't match."))
return password2
当然,一定有更好的方法。
if len(password1) < 7
不会接受长度为7的密码(不足8个字符),对吗? - Dirk