diff --git a/greenweb/settings/development.py b/greenweb/settings/development.py index 26c73388..ac30e5d5 100644 --- a/greenweb/settings/development.py +++ b/greenweb/settings/development.py @@ -13,6 +13,22 @@ INSTALLED_APPS.insert(0, "whitenoise.runserver_nostatic") # noqa +# this snippet allows us to see the hierarchy of templates used to render a page +# without it DEBUG_TOOLBAR runs out of "cache slots", and shows a message saying: + +# "Data for this panel isn't available anymore. Please reload the page and retry." + +# For more, see: +# https://timonweb.com/django/fixing-the-data-for-this-panel-isnt-available-anymore-error-in-django-debug-toolbar/ +if DEBUG: + hide_toolbar_patterns = ["/media/", "/static/"] + + DEBUG_TOOLBAR_CONFIG = { + "SHOW_TOOLBAR_CALLBACK": lambda request: not any( + request.path.startswith(p) for p in hide_toolbar_patterns + ), + } + # Insert debug_toolbar middleware as first element # https://django-debug-toolbar.readthedocs.io/en/latest/installation.html#middleware