Refs -- Added django.views.debug.get_caller() hook.
@@ -85,6 +85,16 @@ def get_exception_reporter_class(request):
return getattr(request, 'exception_reporter_class', default_exception_reporter_class)
+def get_caller(request):
+ resolver_match = request.resolver_match
+ if resolver_match is None:
+ try:
+ resolver_match = resolve(request.path)
+ except Http404:
+ pass
+ return '' if resolver_match is None else resolver_match._func_path
+
+
class SafeExceptionReporterFilter:
"""
Use annotations made by the sensitive_post_parameters and
@@ -536,13 +546,6 @@ def technical_404_response(request, exception):
if isinstance(urlconf, types.ModuleType):
urlconf = urlconf.__name__
- resolver_match = request.resolver_match
- if resolver_match is None:
- try:
- resolver_match = resolve(request.path)
- except Http404:
- pass
-
with builtin_template_path('technical_404.html').open(encoding='utf-8') as fh:
t = DEBUG_ENGINE.from_string(fh.read())
reporter_filter = get_default_exception_reporter_filter()
@@ -555,7 +558,7 @@ def technical_404_response(request, exception):
'reason': str(exception),
'request': request,
'settings': reporter_filter.get_safe_settings(),
- 'raising_view_name': '' if resolver_match is None else resolver_match._func_path,
+ 'raising_view_name': get_caller(request),
})
return HttpResponseNotFound(t.render(c), content_type='text/html')
