您好我无法找到一个验证,一个charfield必须与另一个charfieldCharfield必须与另一个Charfield Django的表单验证匹配
比如我想这NEW_PASSWORD必须confirm_new_password匹配验证匹配的文档:
class ChangePassword(forms.Form):
new_password = forms.CharField(label='New Password', max_length=100, error_messages={'required': 'New password is required'}, widget=forms.PasswordInput())
confirm_new_password = forms.CharField(label='Confirm New Password', max_length=100, error_messages={'required': 'Confirm New password is required'}, widget=forms.PasswordInput())
https://docs.djangoproject.com/en/1.9/ref/forms/fields/#charfield
看来主要的有required, max_length, min_length
?
[清洁和互相依赖的验证领域(https://docs.djangoproject.com /en/1.9/ref/forms/validation/#cleaning-and-validating-fields-that-depend-on-each-other) – Sayse
它是表单验证下的第一个标题之一。 – Sayse
请注意,Django带有内置身份验证[视图](https://docs.djangoproject.com/en/1.9/topics/auth/default/#built-in-auth-views)和[窗体](https:/ /docs.djangoproject.com/en/1.9/topics/auth/default/#built-in-auth-forms)来处理更改密码。使用这些而不是写你自己的。 – Alasdair