비밀 번호 재설정 양식에 대한 새로운 방법 (길이, 문자, ...)에 대한 몇 가지 테스트를 만들기 위해 내 자신의 방법을 쓰고 싶습니다.비밀 번호 재설정 양식, 자신의 깨끗한 방법
class PasswordResetForm(SetPasswordForm):
def clean(self):
if 'newpassword1' in self.cleaned_data and 'newpassword2' in self.cleaned_data:
if self.cleaned_data['newpassword1'] != self.cleaned_data['newpassword2']:
raise forms.ValidationError(("The two password fields didn't match."))
#here the passwords entered are the same
if len(self.cleaned_data['newpassword1']) < 8:
raise forms.ValidationError(("Your password has to be at least 8 characters long"))
if not re.search('\d+', self.cleaned_data['newpassword1']) or not re.search('([a-zA-Z])+', self.cleaned_data['new password1']):
raise forms.ValidationError(("Your password needs to contain at least one number and one character"))
return self.cleaned_data
을하고 urls.py에서 나는이 추가 : 그래서 난 내 forms.py에이 클래스를 추가
url(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', django.contrib.auth.views.password_reset_confirm, {'template_name':'registration/password_reset_confirm.html',
'set_password_form': PasswordResetForm})
을하지만 내 자신의 깨끗한 메서드가 호출되지 않습니다. 이게 뭐니?
나를 위해하지 않았습니다. 여전히 같은 문제. breakpoint를 clean 함수로 설정하면 호출되지 않습니다. 그래서 문제는 다른 곳에서해야합니다. – Kai