From 18a15bbc9c7df19fe38f252bcd62d5a3811e3451 Mon Sep 17 00:00:00 2001 From: Hrushikesh Vaidya Date: Wed, 12 Jan 2022 12:23:09 +0530 Subject: [PATCH] Fixed #33433 -- Avoided unnecessary resolve() calls in technical_404_response(). Thanks Keryn Knight for the initial patch. --- django/views/debug.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/django/views/debug.py b/django/views/debug.py index cff199ddb4..29291c0bf6 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -537,11 +537,13 @@ def technical_404_response(request, exception): urlconf = urlconf.__name__ caller = '' - try: - resolver_match = resolve(request.path) - except Http404: - pass - else: + 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'):