[1.2.X] Fixed #11990 -- Show the correct URLconf in the technical 404 template even if it was overridden, e.g. in a middleware. Thanks, mattbennett.
Backport from trunk (r14877). git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14902 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
3c208d1cca
commit
38d848a3fe
|
@ -2,6 +2,7 @@ import datetime
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import types
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
|
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
|
||||||
|
@ -275,8 +276,13 @@ def technical_404_response(request, exception):
|
||||||
# tried exists but is an empty list. The URLconf must've been empty.
|
# tried exists but is an empty list. The URLconf must've been empty.
|
||||||
return empty_urlconf(request)
|
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')
|
t = Template(TECHNICAL_404_TEMPLATE, name='Technical 404 template')
|
||||||
c = Context({
|
c = Context({
|
||||||
|
'urlconf': urlconf,
|
||||||
'root_urlconf': settings.ROOT_URLCONF,
|
'root_urlconf': settings.ROOT_URLCONF,
|
||||||
'request_path': request.path_info[1:], # Trim leading slash
|
'request_path': request.path_info[1:], # Trim leading slash
|
||||||
'urlpatterns': tried,
|
'urlpatterns': tried,
|
||||||
|
@ -773,7 +779,7 @@ TECHNICAL_404_TEMPLATE = """
|
||||||
<div id="info">
|
<div id="info">
|
||||||
{% if urlpatterns %}
|
{% if urlpatterns %}
|
||||||
<p>
|
<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:
|
Django tried these URL patterns, in this order:
|
||||||
</p>
|
</p>
|
||||||
<ol>
|
<ol>
|
||||||
|
|
Loading…
Reference in New Issue