Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#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


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/
--- django/core/   (revision 247)
+++ django/core/   (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

Change History (1)

comment:1 Changed 14 years ago by Jacob

Resolution: fixed
Status: newclosed

(In [270]) Fixed #132 -- thanks anonymous user

Note: See TracTickets for help on using tickets.
Back to Top