Fixed #27373 -- Corrected 404 debug page message for an empty request path.
This commit is contained in:
parent
968f61b991
commit
c7f86d3eec
|
@ -1193,7 +1193,11 @@ TECHNICAL_404_TEMPLATE = """
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ol>
|
</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 %}
|
{% else %}
|
||||||
<p>{{ reason }}</p>
|
<p>{{ reason }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
from unittest import skipIf
|
from unittest import skipIf
|
||||||
|
|
||||||
|
from django.conf.urls import url
|
||||||
from django.core import mail
|
from django.core import mail
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
from django.db import DatabaseError, connection
|
from django.db import DatabaseError, connection
|
||||||
|
@ -28,9 +29,10 @@ from django.views.debug import (
|
||||||
|
|
||||||
from .. import BrokenException, except_args
|
from .. import BrokenException, except_args
|
||||||
from ..views import (
|
from ..views import (
|
||||||
custom_exception_reporter_filter_view, multivalue_dict_key_error,
|
custom_exception_reporter_filter_view, index_page,
|
||||||
non_sensitive_view, paranoid_view, sensitive_args_function_caller,
|
multivalue_dict_key_error, non_sensitive_view, paranoid_view,
|
||||||
sensitive_kwargs_function_caller, sensitive_method_view, sensitive_view,
|
sensitive_args_function_caller, sensitive_kwargs_function_caller,
|
||||||
|
sensitive_method_view, sensitive_view,
|
||||||
)
|
)
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
|
@ -44,6 +46,10 @@ class User(object):
|
||||||
return 'jacob'
|
return 'jacob'
|
||||||
|
|
||||||
|
|
||||||
|
class WithoutEmptyPathUrls:
|
||||||
|
urlpatterns = [url(r'url/$', index_page, name='url')]
|
||||||
|
|
||||||
|
|
||||||
class CallableSettingWrapperTests(SimpleTestCase):
|
class CallableSettingWrapperTests(SimpleTestCase):
|
||||||
""" Unittests for CallableSettingWrapper
|
""" Unittests for CallableSettingWrapper
|
||||||
"""
|
"""
|
||||||
|
@ -115,6 +121,11 @@ class DebugViewTests(LoggingCaptureMixin, SimpleTestCase):
|
||||||
self.assertNotContains(response, "Raised by:", status_code=404)
|
self.assertNotContains(response, "Raised by:", status_code=404)
|
||||||
self.assertContains(response, "<code>not-in-urls</code>, didn't match", 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):
|
def test_technical_404(self):
|
||||||
response = self.client.get('/views/technical404/')
|
response = self.client.get('/views/technical404/')
|
||||||
self.assertContains(response, "Raised by:", status_code=404)
|
self.assertContains(response, "Raised by:", status_code=404)
|
||||||
|
|
Loading…
Reference in New Issue