Refs 32637 -- Made technical 404 debug page display exception message when URL is resolved.

Follow up to 3b8527e32b.
This commit is contained in:
Mariusz Felisiak 2021-04-27 08:40:52 +02:00 committed by GitHub
parent eab71f7690
commit d68be0494b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -26,7 +26,7 @@
<body> <body>
<div id="summary"> <div id="summary">
<h1>Page not found <span>(404)</span></h1> <h1>Page not found <span>(404)</span></h1>
{% if reason %}<pre class="exception_value">{{ reason }}</pre>{% endif %} {% if reason and resolved %}<pre class="exception_value">{{ reason }}</pre>{% endif %}
<table class="meta"> <table class="meta">
<tr> <tr>
<th>Request Method:</th> <th>Request Method:</th>

View File

@ -122,6 +122,11 @@ class DebugViewTests(SimpleTestCase):
def test_404(self): def test_404(self):
response = self.client.get('/raises404/') response = self.client.get('/raises404/')
self.assertNotContains(
response,
'<pre class="exception_value">',
status_code=404,
)
self.assertContains( self.assertContains(
response, response,
'<p>The current path, <code>not-in-urls</code>, didnt match any ' '<p>The current path, <code>not-in-urls</code>, didnt match any '
@ -133,6 +138,11 @@ class DebugViewTests(SimpleTestCase):
def test_404_not_in_urls(self): def test_404_not_in_urls(self):
response = self.client.get('/not-in-urls') response = self.client.get('/not-in-urls')
self.assertNotContains(response, "Raised by:", status_code=404) self.assertNotContains(response, "Raised by:", status_code=404)
self.assertNotContains(
response,
'<pre class="exception_value">',
status_code=404,
)
self.assertContains(response, "Django tried these URL patterns", status_code=404) self.assertContains(response, "Django tried these URL patterns", status_code=404)
self.assertContains( self.assertContains(
response, response,