我在django 1.6.1最终版本和python 2.7中使用。我创建了一个表单模型:
class EditUserForm(forms.Form):
password1 = forms.CharField(max_length=45, label='', required=False,
widget=forms.PasswordInput(attrs={'placeholder': 'Пароль',
'class': 'form-control', }))
password2 = forms.CharField(max_length=45, label='', required=False,
widget=forms.PasswordInput(attrs={'placeholder': 'Подтверждение пароля',
'class': 'form-control', }))
email = forms.CharField(max_length=45, label='',
widget=forms.TextInput(attrs={'placeholder': 'E-mail',
'class': 'form-control', }))
phone = forms.CharField(max_length=45, label='',
widget=forms.TextInput(attrs={'placeholder': 'Телефон',
'class': 'form-control', }))
当我提交此表单并尝试调用is_valid()
方法时,如果This field is required
或password1
为空(但它设置为{{1},则会引发错误password2
}}?)。如果我尝试设置required=False
,则会引发错误blank=True
。有什么问题?