NOT必填字段抛出错误'此字段为必填项'

时间:2014-01-17 11:31:44

标签: python django python-2.7

我在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 requiredpassword1为空(但它设置为{{1},则会引发错误password2 }}?)。如果我尝试设置required=False,则会引发错误blank=True。有什么问题?

0 个答案:

没有答案