Fixed #27373 -- Corrected 404 debug page message for an empty request path.

This commit is contained in:
Mariusz Felisiak 2016-10-27 22:58:41 +02:00 committed by Tim Graham
parent 968f61b991
commit c7f86d3eec
2 changed files with 19 additions and 4 deletions

View File

@ -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 %}

View File

@ -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)