ReCaptcha for django forms (improved and with remoteip)
My previous snippet with captcha wasn't very portable but Marco Fucci figured out the thing that I couldn't - value_from_datadict function. So all credits go to him and his snippet, I adapted it to my needs, maybe you like my version better - it doesn't need any captcha libraries and let's you modify the widget's html easily. Also I added an option to pass remoteip to google api's verify method. How to use it: In your settings.py add: RECAPTCHA_PUBKEY = 'your recaptcha public key' RECAPTCHA_PRIVKEY = 'your recaptcha private key' After that just import and use ReCaptchaField in your form as you would any other field. That's it. *** Important *** If you want to have peace of mind in case google decided that the remoteip parametr is mandatory then: Derive every form that has the captcha field from ReCaptchaForm and when you create the form object after receiving POST/GET, pass a remoteip parameter like that: form = YourCaptchaForm(data=request.POST, remoteip=request.META['REMOTE_ADDR'])
- forms
- captcha
- recaptcha