summaryrefslogtreecommitdiff
path: root/django/views/debug.py
diff options
context:
space:
mode:
authorHrushikesh Vaidya <hrushikeshrv@gmail.com>2022-01-12 19:02:19 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-01-12 15:56:59 +0100
commitd05ab13c56849ed09d02c1f188b7f47f0c090a2a (patch)
treeeae0eb29492074e5fd78a844b7283d3bc2b5bf8f /django/views/debug.py
parent84e98ba19456a03f355c3f01ba6c70d5f45ee260 (diff)
Refs #33426 -- Simplified technical_404_response() with ResolverMatch._func_path.
Diffstat (limited to 'django/views/debug.py')
-rw-r--r--django/views/debug.py17
1 files changed, 1 insertions, 16 deletions
diff --git a/django/views/debug.py b/django/views/debug.py
index 29291c0bf6..ab66f56a97 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -536,27 +536,12 @@ def technical_404_response(request, exception):
if isinstance(urlconf, types.ModuleType):
urlconf = urlconf.__name__
- caller = ''
resolver_match = request.resolver_match
if resolver_match is None:
try:
resolver_match = resolve(request.path)
except Http404:
pass
- if resolver_match is not None:
- obj = resolver_match.func
-
- if hasattr(obj, 'view_class'):
- obj = obj.view_class
-
- if hasattr(obj, '__name__'):
- caller = obj.__name__
- elif hasattr(obj, '__class__') and hasattr(obj.__class__, '__name__'):
- caller = obj.__class__.__name__
-
- if hasattr(obj, '__module__'):
- module = obj.__module__
- caller = '%s.%s' % (module, caller)
with builtin_template_path('technical_404.html').open(encoding='utf-8') as fh:
t = DEBUG_ENGINE.from_string(fh.read())
@@ -570,7 +555,7 @@ def technical_404_response(request, exception):
'reason': str(exception),
'request': request,
'settings': reporter_filter.get_safe_settings(),
- 'raising_view_name': caller,
+ 'raising_view_name': '' if resolver_match is None else resolver_match._func_path,
})
return HttpResponseNotFound(t.render(c), content_type='text/html')