praekelt/django-recaptcha — Issue #9: Error when request.META['REMOTE_ADDR'] is not defined
Author: JoeJasinski
Created: 2012-01-11 03:46:27+00:00
State: open

Hi, I got an error when using this module because for some reason or another request.META['REMOTE_ADDR'] was not set by my django instance. I think this probably has to do with the way that the request is being proxied. I don't think that REMOTE_ADDR is always something that can be depended on as being set all the time. I made the following change which I think solves the issue.

Solution:

https://github.com/JoeJasinski/django-recaptcha/commit/5fdb9bc22dca944758285c0defc5560076213f81

Original Error:

File "/jaz/sites/jazstudios/lib/python2.6/site-packages/captcha/fields.py", line 53, in clean
remoteip=self.get_remote_ip(), use_ssl=self.use_ssl)

File "/jaz/sites/jazstudios/lib/python2.6/site-packages/captcha/fields.py", line 44, in get_remote_ip
return request.META['REMOTE_ADDR']

KeyError: 'REMOTE_ADDR'