我正在整理一个在站点上具有表单的Django应用程序,但我是手动呈现这些表单的(即实际上输入每个字段并使用AJAX提交)。
如何将Recaptcha集成到表单中?谢谢您的帮助!
最佳答案
我只是使用此python客户端进行recaptcha:
http://pypi.python.org/pypi/recaptcha-client
那么我的观点看起来像这样:
captcha_key = get_config('RECAPTCHA_PUB_KEY',None)
recaptcha_challenge_field = request.POST.get('recaptcha_challenge_field', None)
recaptcha_response_field = request.POST.get('recaptcha_response_field', None)
check_captcha = captcha.submit(recaptcha_challenge_field, recaptcha_response_field, settings.RECAPTCHA_PRIVATE_KEY, request.META['REMOTE_ADDR'])
if check_captcha.is_valid is False:
log.info('captcha_error : %s' % check_captcha.error_code)
return {'TEMPLATE':template_name,'captcha_error': True,'register_form': f,'captcha_key':captcha_key ,'next':redirect_to}
关于python - Django中的Recaptcha没有形式?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8380972/