当一个字段为空时,为什么会出现 keyerror 而不是验证错误?这些字段应required=True
默认为
class form(forms.ModelForm):
adminAccount = forms.CharField()
adminPassword = forms.CharField(widget=forms.PasswordInput)
def userCheck(self, user, password):
# do something
def clean(self):
self.userCheck(self.cleaned_data['adminAccount'],
self.cleaned_data['adminPassword'])