diff --git a/debug_toolbar/panels/cache.py b/debug_toolbar/panels/cache.py index e7f3f467e..b4c486124 100644 --- a/debug_toolbar/panels/cache.py +++ b/debug_toolbar/panels/cache.py @@ -6,8 +6,7 @@ try: from django.utils.connection import ConnectionProxy except ImportError: - # Django 3.1 and below doesn't have a ConnectionProxy - pass + ConnectionProxy = None from django.conf import settings from django.core import cache @@ -257,10 +256,9 @@ def enable_instrumentation(self): else: cache.caches = CacheHandlerPatch() - try: + # Wrap the patched cache inside Django's ConnectionProxy + if ConnectionProxy: cache.cache = ConnectionProxy(cache.caches, DEFAULT_CACHE_ALIAS) - except NameError: - pass def disable_instrumentation(self): cache.caches = original_caches