【发布时间】:2018-07-28 10:57:02
【问题描述】:
我很困惑,django 会自动调用 clean_botcatcher(self): 吗?它是否充当侦听器,当机器人对值进行更改时触发?
from django import forms
class FormName(forms.Form):
name = forms.CharField()
email = forms.EmailField()
text = forms.CharField(widget=forms.Textarea)
botcatcher = forms.CharField(required=False,widget =forms.HiddenInput)
def clean_botcatcher(self):
botcatcher = self.cleaned_data['botcatcher']
if len(botcatcher) > 0:
raise forms.ValidationError("Gotcha BOT")
return botcatcher
【问题讨论】:
标签: django django-forms django-validation