Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10678 closed (duplicate)

Confusing error when django.root has a trailing slash

Reported by: Rick Dean Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: django.root mod_python
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


If using mod_python, and django.root has a trailing
slash, then some pages fail with a confusing "NoneType
is not iterable" error on line 82 of core/handlers/
because request.path_info is None. The following patch
fixes it by silently truncating the configurable.

Also, can we please add double quotes around the value
of example django.root setting on

Attachments (2)

rick.diff (708 bytes) - added by Rick Dean 7 years ago.
patch to correct bad configurable values
django-10678.diff (645 bytes) - added by Adam Vollrath 7 years ago.
Alternative patch raising ValueError when a bad django.root is configured

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by Rick Dean

Attachment: rick.diff added

patch to correct bad configurable values

comment:1 Changed 7 years ago by Jacob

milestone: 1.1
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Jacob

Resolution: worksforme
Status: newclosed

I can't reproduce this problem with or without the patch. The fact that "some page fail" indicates that it's not something this cut and dry. Also, note that the lines following guard against an empty path_info (line 33) so just striping the slash won't change that.

I'm marking worksforme; please feel free to reopen if you find more information.

comment:3 Changed 7 years ago by Adam Vollrath

Keywords: django.root mod_python added
milestone: 1.11.2
Resolution: worksforme
Status: closedreopened

I can consistently induce a similar error by setting django.root to simply '/'. Here's the maddening Traceback:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib64/python2.4/site-packages/mod_python/", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/", line 230, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/", line 203, in __call__
    response = self.get_response(request)

  File "/usr/lib/python2.4/site-packages/django/core/handlers/", line 115, in get_response
    return debug.technical_404_response(request, e)

  File "/usr/lib/python2.4/site-packages/django/views/", line 247, in technical_404_response
    tried = exception.args[0]['tried']

KeyError: 'tried'

I admit that setting django.root to '/' was a mistake, but this took me over an hour to track down. I'd like to help out others who might make the same mistake. I'll attach a patch that raises an exception when a bad django.root is used.

Changed 7 years ago by Adam Vollrath

Attachment: django-10678.diff added

Alternative patch raising ValueError when a bad django.root is configured

comment:4 Changed 7 years ago by Malcolm Tredinnick

Resolution: duplicate
Status: reopenedclosed

Duplicate of #9270. Anybody putting django.root = "/" hasn't read the documentation for how django.root is being used, by the way. It's never required.

comment:5 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

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