You can see how Django itself validates the password:
https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L64
On 18.07.2017 12:51, 'Tom Evans' via Django users wrote:
As described in the docs on form and field validation, if you want to
validate one field using another field, you do so in the clean()
method:
https://docs.djangoproject.com/en/1.8/ref/forms/validation/
and in detail
https://docs.djangoproject.com/en/1.8/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other
Cheers
Tom
On Tue, Jul 18, 2017 at 10:19 AM, 李余通 <liyutong19961...@gmail.com> wrote:
My mind is here:
class Register(forms.Form):
passwd =
forms.CharField(max_length=20,label='密码',widget=forms.PasswordInput)
repasswd =
forms.CharField(max_length=20,label='重复密码',widget=forms.PasswordInput)
def clean_passwd(self):
passwd = self.cleaned_data['passwd']
repasswd = self.cleaned_data['repasswd'] #here is error
if passwd != repasswd:
raise forms.ValidationError('两次密码不一致')
return passwd
So,problems is i want to check passwd and repasswd same,How to solve?
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/ab8a7050-37c8-4547-9b86-5bd16821ede9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Jani Tiainen
--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/a516d4ad-bcfe-4838-ec84-ff6d96260997%40gmail.com.
For more options, visit https://groups.google.com/d/optout.