我試圖在我的窗體上實現Django reCAPTCHA。問題是,它沒有驗證每次reCAPTCHA會話,我正確地提交表單。我試圖提交reCAPTCHA表格大約30次,並且仍然不驗證reCAPTCHA。Django reCAPTCHA不驗證響應
我在開發服務器上實現了reCAPTCHA,並將域名添加爲www.example.com。
我還使用本教程http://www.chrisumbel.com/article/recaptcha_with_django
這可能是原因所在,它不會因爲驗證,我使用的發展,否則有人可以幫我嗎?
from django.contrib.auth.views import password_reset
from django.shortcuts import render
from recaptcha.client import captcha
def forgot_password(request):
if request.method == 'POST':
response = captcha.submit(request.POST.get('recaptcha_challenge_field'), request.POST.get('recaptcha_response_field'), '1231d12dsad12', request.META['REMOTE_ADDR'],)
if response.is_valid:
captcha_response = "YOU ARE HUMAN: %(data)s" % {'data' : edit_form.data['data_field']}
else:
captcha_response = 'YOU ARE ROBOT'
return render(request, 'forgot_password.html',{'captcha_response':captcha_response})
else:
return render(request, 'forgot_password.html')
模板
{% block title %}Forgot Password<br>{% endblock title %}
<form method="post" action="{% url accounts:forgot-password %}">
{% csrf_token %}
<p>Please enter your email address.
You will receive a link to create a new password via email.</p>
<input type="email" name="email"
placeholder="Your e-mail"><br/>
<th>Are you human?</th>
<span class="validation_error">{{ captcha_response }}</span>
<script type="text/javascript"
src="http://api.recaptcha.net/challenge?k=123dwqsdasd123e23d32d32">
</script>
<noscript>
<iframe src="http://api.recaptcha.net/noscript?k=123dwqsdasd123e23d32d32">
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>
<button type="submit">Send new password</button>
</form>
嘗試使您的reCaptcha鍵全局化,如果您尚未完成。 –
@Piotr Jaszkowski你能解釋一下更多關於製作全球關鍵 – donkeyboy72
啊對不起,你不能改變關鍵是全球性的。但是,您可以在此網站上啓用全局選項並創建新的:https://www.google.com/recaptcha/admin/create –