Cache panel does not handle imported "caches" on module level

Author: blueyedCreated Jan 11, 2016Updated Aug 8, 2026
LabelsBug

When using from django.core.cache import caches in a module, that is loaded only before a view is processed, this caches.caches instance will not be monkey-patched via CacheHandlerPatch.

One possible workaround would be to not use enable_instrumentation / disable_instrumentation for this, but do it in debug_toolbar.panels.cache on import time.

enable_instrumentation / disable_instrumentation could then be used still to enable/disable sending the signals, but caches would be wrapped always.

Source: django-commons/django-debug-toolbar