From 6261593b998ed205b3d45833926cf75756384a13 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Sun, 12 Dec 2010 22:54:04 +0000 Subject: [PATCH] Fixed #11990 -- Show the correct URLconf in the technical 404 template 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 --- django/views/debug.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/views/debug.py b/django/views/debug.py index 5c75a49e9a..233f694b21 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -2,6 +2,7 @@ import datetime import os import re import sys +import types from django.conf import settings from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound @@ -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, @@ -787,7 +793,7 @@ TECHNICAL_404_TEMPLATE = """
{% if urlpatterns %}

- Using the URLconf defined in {{ settings.ROOT_URLCONF }}, + Using the URLconf defined in {{ urlconf }}, Django tried these URL patterns, in this order: