Skip to content

Commit

Permalink
Fixed #11990 -- Show the correct URLconf in the technical 404 templat…
Browse files Browse the repository at this point in the history
…e even if it was overridden, e.g. in a middleware. Thanks, mattbennett.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@14877 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
jezdez committed Dec 12, 2010
1 parent 462d311 commit 6261593
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion django/views/debug.py
Expand Up @@ -2,6 +2,7 @@
import os
import re
import sys
import types

from django.conf import settings
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
Expand Down Expand Up @@ -277,8 +278,13 @@ def technical_404_response(request, exception):
# tried exists but is an empty list. The URLconf must've been empty.
return empty_urlconf(request)

urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
if isinstance(urlconf, types.ModuleType):
urlconf = urlconf.__name__

t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
c = Context({
'urlconf': urlconf,
'root_urlconf': settings.ROOT_URLCONF,
'request_path': request.path_info[1:], # Trim leading slash
'urlpatterns': tried,
Expand Down Expand Up @@ -787,7 +793,7 @@ def empty_urlconf(request):
<div id="info">
{% if urlpatterns %}
<p>
Using the URLconf defined in <code>{{ settings.ROOT_URLCONF }}</code>,
Using the URLconf defined in <code>{{ urlconf }}</code>,
Django tried these URL patterns, in this order:
</p>
<ol>
Expand Down

0 comments on commit 6261593

Please sign in to comment.