summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/views/debug.py6
-rw-r--r--tests/view_tests/tests/test_debug.py17
2 files changed, 19 insertions, 4 deletions
diff --git a/django/views/debug.py b/django/views/debug.py
index f7c685893c..1a72ec0405 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -1193,7 +1193,11 @@ TECHNICAL_404_TEMPLATE = """
</li>
{% endfor %}
</ol>
- <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p>
+ <p>
+ {% if request_path %}
+ The current path, <code>{{ request_path|escape }}</code>,{% else %}
+ The empty path{% endif %} didn't match any of these.
+ </p>
{% else %}
<p>{{ reason }}</p>
{% endif %}
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index ba6e6defee..44a6a360e4 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -11,6 +11,7 @@ import sys
import tempfile
from unittest import skipIf
+from django.conf.urls import url
from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import DatabaseError, connection
@@ -28,9 +29,10 @@ from django.views.debug import (
from .. import BrokenException, except_args
from ..views import (
- custom_exception_reporter_filter_view, multivalue_dict_key_error,
- non_sensitive_view, paranoid_view, sensitive_args_function_caller,
- sensitive_kwargs_function_caller, sensitive_method_view, sensitive_view,
+ custom_exception_reporter_filter_view, index_page,
+ multivalue_dict_key_error, non_sensitive_view, paranoid_view,
+ sensitive_args_function_caller, sensitive_kwargs_function_caller,
+ sensitive_method_view, sensitive_view,
)
if six.PY3:
@@ -44,6 +46,10 @@ class User(object):
return 'jacob'
+class WithoutEmptyPathUrls:
+ urlpatterns = [url(r'url/$', index_page, name='url')]
+
+
class CallableSettingWrapperTests(SimpleTestCase):
""" Unittests for CallableSettingWrapper
"""
@@ -115,6 +121,11 @@ class DebugViewTests(LoggingCaptureMixin, SimpleTestCase):
self.assertNotContains(response, "Raised by:", status_code=404)
self.assertContains(response, "<code>not-in-urls</code>, didn't match", status_code=404)
+ @override_settings(ROOT_URLCONF=WithoutEmptyPathUrls)
+ def test_404_empty_path_not_in_urls(self):
+ response = self.client.get('/')
+ self.assertContains(response, "The empty path didn't match any of these.", status_code=404)
+
def test_technical_404(self):
response = self.client.get('/views/technical404/')
self.assertContains(response, "Raised by:", status_code=404)