我已经能够让recpatcha正确显示并提交我想将验证码放在前面的表单,但无论您在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=[('', ''), ('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)
我正在使用 App Engine,在我的处理程序中我有这个
def post(self):
message_form = MessageForm(self.request.POST, captcha={'ip_address': str(self.request.remote_addr)})
其他人知道我是否缺少某些东西?表单发布后,RecaptchaField 似乎拥有所有正确的数据(即 challenge_field 等)。
感谢您的任何建议。