Fixed #33425 -- Fixed view name for CBVs on technical 404 debug page.

Regression in 0c0b87725b.
This commit is contained in:
Keryn Knight 2022-01-07 12:57:03 +00:00 committed by Mariusz Felisiak
parent 7346c288e3
commit 2a66c102d9
3 changed files with 17 additions and 5 deletions

View File

@ -545,8 +545,9 @@ def technical_404_response(request, exception):
obj = resolver_match.func
if hasattr(obj, 'view_class'):
caller = obj.view_class
elif hasattr(obj, '__name__'):
obj = obj.view_class
if hasattr(obj, '__name__'):
caller = obj.__name__
elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
caller = obj.__class__.__name__

View File

@ -14,3 +14,6 @@ Bugfixes
* Fixed a regression in Django 4.0 where ``help_text`` was HTML-escaped in
automatically-generated forms (:ticket:`33419`).
* Fixed a regression in Django 4.0 that caused displaying an incorrect name for
class-based views on the technical 404 debug page (:ticket:`33425`).

View File

@ -177,7 +177,11 @@ class DebugViewTests(SimpleTestCase):
html=True,
)
self.assertContains(response, "Raised by:", status_code=404)
self.assertContains(response, "view_tests.views.technical404", status_code=404)
self.assertContains(
response,
'<td>view_tests.views.technical404</td>',
status_code=404,
)
self.assertContains(
response,
'<p>The current path, <code>technical404/</code>, matched the '
@ -188,8 +192,12 @@ class DebugViewTests(SimpleTestCase):
def test_classbased_technical_404(self):
response = self.client.get('/classbased404/')
self.assertContains(response, "Raised by:", status_code=404)
self.assertContains(response, "view_tests.views.Http404View", status_code=404)
self.assertContains(
response,
'<th>Raised by:</th><td>view_tests.views.Http404View</td>',
status_code=404,
html=True,
)
def test_non_l10ned_numeric_ids(self):
"""