#132 closed defect (fixed)
REMOTE_ADDR not in WSGI-environ
Reported by: | anonymous | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Core (Other) | Version: | |
Severity: | normal | Keywords: | wsgi |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The WSGI-spec does not promise the presence of 'REMOTE_ADDR' in environ, but DjangoContext reads it unconditionally when checking if it is in INTERNAL_IPS.
Here is a short patch to fix this, by using .get instead of [].
Index: django/core/extensions.py =================================================================== --- django/core/extensions.py (revision 247) +++ django/core/extensions.py (working copy) @@ -13,7 +13,7 @@ self['user'] = request.user self['messages'] = request.user.get_and_delete_messages() self['perms'] = PermWrapper(request.user) - if DEBUG and request.META['REMOTE_ADDR'] in INTERNAL_IPS: + if DEBUG and request.META.get('REMOTE_ADDR') in INTERNAL_IPS: self['debug'] = True from django.core import db self['sql_queries'] = db.db.queries
Note:
See TracTickets
for help on using tickets.
(In [270]) Fixed #132 -- thanks anonymous user