2๐
You could do your own implementation:
import urllib, urllib2, re
def recaptcha(request, postdata):
rc_challenge = postdata.get('recaptcha_challenge_field','')
rc_user_input = postdata.get('recaptcha_response_field', '').encode('utf-8')
url = 'http://www.google.com/recaptcha/api/verify'
values = {'privatekey' : 'PRIVATE-KEY', 'remoteip': request.META['REMOTE_ADDR'], 'challenge' : rc_challenge, 'response' : rc_user_input,}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
answer = response.read().split()[0]
response.close()
return answer
This returns true when captcha was typed right else false.
In your view you could then do something like this:
if request.method == "POST":
postdata = request.POST.copy()
captcha = recaptcha(request, postdata)
if captcha:
#do something
else:
#do something else
You would have to adjust your template a bit, should not be to hard to figure it out. Hope this leads into the right direction.
๐คJingo
- [Answered ]-Django database connection issue
- [Answered ]-How to write this querySet with Django?
- [Answered ]-Does django mess up with python's datetime?
- [Answered ]-Django sitemap โ add loc into sitemap
- [Answered ]-Not able to update choiceField using jquery in django forms
Source:stackexchange.com