Permalink
Browse files

Debug 400 page now displays special error message if your URLconf is …

…empty.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1552 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 54618dc commit 85c369001b750909e616470cb853ceb2301fd71a @adrianholovaty adrianholovaty committed Dec 6, 2005
Showing with 21 additions and 11 deletions.
  1. +21 −11 django/views/debug.py
View
@@ -128,15 +128,21 @@ def technical_404_response(request, exception):
Create a technical 404 error response. The exception should be the Http404
exception.
"""
+ urlconf_is_empty = False
try:
tried = exception.args[0]['tried']
except (IndexError, TypeError):
tried = []
+ else:
+ if not tried:
+ # tried exists but is an empty list. The URLconf must've been empty.
+ urlconf_is_empty = True
t = Template(TECHNICAL_404_TEMPLATE)
c = Context({
'root_urlconf': settings.ROOT_URLCONF,
'urlpatterns': tried,
+ 'urlconf_is_empty': urlconf_is_empty,
'reason': str(exception),
'request': request,
'request_protocol': os.environ.get("HTTPS") == "on" and "https" or "http",
@@ -533,19 +539,23 @@ def _get_lines_from_file(filename, lineno, context_lines):
</table>
</div>
<div id="info">
- {% if urlpatterns %}
- <p>
+ {% if urlconf_is_empty %}
+ <p>Your URLconf, <code>{{ settings.ROOT_URLCONF }}</code>, was empty.</p>
+ {% else %}
+ {% if urlpatterns %}
+ <p>
Using the URLconf defined in <code>{{ settings.ROOT_URLCONF }}</code>,
Django tried these URL patterns, in this order:
- </p>
- <ol>
- {% for pattern in urlpatterns %}
- <li>{{ pattern|escape }}</li>
- {% endfor %}
- </ol>
- <p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p>
- {% else %}
- <p>{{ reason|escape }}</p>
+ </p>
+ <ol>
+ {% for pattern in urlpatterns %}
+ <li>{{ pattern|escape }}</li>
+ {% endfor %}
+ </ol>
+ <p>The current URL, <code>{{ request.path }}</code>, didn't match any of these.</p>
+ {% else %}
+ <p>{{ reason|escape }}</p>
+ {% endif %}
{% endif %}
</div>

0 comments on commit 85c3690

Please sign in to comment.