开发者

Django-registration and ReCaptcha integration - how to pass the user's IP

开发者 https://www.devze.com 2022-12-27 23:19 出处:网络
New to django and trying to setup django-registration 0.8 with recaptcha-client. I followed the advice posted in the answer to this question.

New to django and trying to setup django-registration 0.8 with recaptcha-client. I followed the advice posted in the answer to this question.

I used the custom form and custom backend from that post and the widget and field from this tutorial. My form is displaying properly with the recaptcha widget but when I submit it throws the error about the missing IP. What's the best way 开发者_高级运维to pass the IP using django-registration?


I also used the code from the tutorial you linked, in my case to add reCaptcha to the django comments app.

You need something like initial={'captcha': request.META['REMOTE_ADDR']} at the point where your RecaptchaRegistrationForm gets instantiated.

Unfortunately this is buried in the registration/views.py register method.

You need to do something like copy and paste their code into a view method of your own and edit it. Then you need a urls.py for your customised backend that looks like the one in registration/backends/default/ but points to your new register view in place of theirs.

0

精彩评论

暂无评论...
验证码 换一张
取 消