Skip to content

Commit 29a2ad6

Browse files
committed
Patch default cache when using the cache panel
1 parent ea65261 commit 29a2ad6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.8.2

debug_toolbar/panels/cache.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55

66
from django.conf import settings
77
from django.core import cache
8-
from django.core.cache import CacheHandler, caches as original_caches
8+
from django.core.cache import (
9+
DEFAULT_CACHE_ALIAS,
10+
CacheHandler,
11+
cache as original_cache,
12+
caches as original_caches,
13+
)
914
from django.core.cache.backends.base import BaseCache
1015
from django.dispatch import Signal
1116
from django.middleware import cache as middleware_cache
@@ -246,8 +251,17 @@ def enable_instrumentation(self):
246251
else:
247252
cache.caches = CacheHandlerPatch()
248253

254+
# Patch default cache on Django 3.2
255+
try:
256+
from django.utils.connection import ConnectionProxy
257+
258+
cache.cache = ConnectionProxy(cache.caches, DEFAULT_CACHE_ALIAS)
259+
except ImportError:
260+
pass
261+
249262
def disable_instrumentation(self):
250263
cache.caches = original_caches
264+
cache.cache = original_cache
251265
# While it can be restored to the original, any views that were
252266
# wrapped with the cache_page decorator will continue to use a
253267
# monkey patched cache.

0 commit comments

Comments
 (0)