Wtforms 有人吗?
我已经能够让Recpatca正确显示,并与我想要将验证码放在前面的表单一起提交,但无论您在recaptcha表单中键入什么,它都会验证 这是我的wtforms课程:Wtforms 有人吗?,wtforms,Wtforms,我已经能够让Recpatca正确显示,并与我想要将验证码放在前面的表单一起提交,但无论您在recaptcha表单中键入什么,它都会验证 这是我的wtforms课程: class MessageForm(Form): reason_code = SelectField(u'Reason', [validators.Required(message=(u'A reason for contacting us must be selected.'))], default = -1, choices
class MessageForm(Form):
reason_code = SelectField(u'Reason', [validators.Required(message=(u'A reason for contacting us must be selected.'))], default = -1, choices=[('', ''), ('0', 'Advertising'), ('1', 'Comments/Suggestions'), ('2', 'Support')])
reply_to = TextField(u'Email address', [validators.Required(message=(u'A reply to email address is required.')), validators.Email(message=(u'A valid reply to email address is required.'))])
message_body = TextAreaField(u'Message', [validators.Required(u'You must enter a message to submit this form.')])
captcha = RecaptchaField(u'Captcha', [validators.Required(u'You must properly fill in the Captcha to submit this form.')], public_key=esp_constants.DEV_RECAPTCHA_PUBLIC_KEY, private_key=esp_constants.DEV_RECAPTCHA_PRIVATE_KEY, secure=True)
我正在使用AppEngine,在我的表单处理程序中有
def post(self):
message_form = MessageForm(self.request.POST, captcha={'ip_address': str(self.request.remote_addr)})
还有人知道我是否遗漏了什么吗?表单发布后,RecaptchaField似乎拥有所有正确的数据(即挑战_字段等)
感谢您的建议。Flask WTF支持Recaptcha(请参阅),因此他们的代码可能会对您有所帮助(特别是:)。我最终不得不自己动手让WebApp2、Recaptcha和WTForms的组合在Google App Engine中可靠地工作 这就是我在基本控制器中作为验证方法处理它的基本方式 recaptcha HTML片段如下所示: 对于recaptcha字段值,我使用了标准HiddenField,而不是RecaptchaField类型,如下所示: 验证码=隐藏字段(“重新验证码”)
干杯当我最初问这个问题时,我看了看这些,但它们不能与WebApp2正常工作。最后我滚动了我自己的-见对我自己问题的回答。