diff options
| -rw-r--r-- | debug_toolbar/panels/__init__.py | 3 | ||||
| -rw-r--r-- | debug_toolbar/settings.py | 23 | ||||
| -rw-r--r-- | docs/configuration.rst | 6 | 
3 files changed, 20 insertions, 12 deletions
| diff --git a/debug_toolbar/panels/__init__.py b/debug_toolbar/panels/__init__.py index e71d7b6..a7e3528 100644 --- a/debug_toolbar/panels/__init__.py +++ b/debug_toolbar/panels/__init__.py @@ -5,6 +5,7 @@ import warnings  from django.template.loader import render_to_string  from debug_toolbar import settings as dt_settings +from debug_toolbar.utils import get_name_from_obj  class Panel(object): @@ -23,7 +24,7 @@ class Panel(object):      @property      def enabled(self):          # Check to see if settings has a default value for it -        if self.panel_id in dt_settings.CONFIG['DEFAULT_DISABLED_PANELS']: +        if get_name_from_obj(self) in dt_settings.CONFIG['DEFAULT_DISABLED_PANELS']:              default = 'off'          else:              default = 'on' diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 2d02aa5..0ea75ab 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -16,7 +16,7 @@ from django.utils import six  CONFIG_DEFAULTS = {      # Toolbar options -    'DEFAULT_DISABLED_PANELS': ('RedirectsPanel', ), +    'DEFAULT_DISABLED_PANELS': {'debug_toolbar.panels.redirects.RedirectsPanel'},      'INSERT_BEFORE': '</body>',      'RENDER_PANELS': None,      'RESULTS_STORE_SIZE': 10, @@ -131,15 +131,22 @@ if 'INTERCEPT_REDIRECTS' in USER_CONFIG:          "DEFAULT_DISABLED_PANELS config in the"          "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)      if USER_CONFIG['INTERCEPT_REDIRECTS']: -        if 'RedirectsPanel' in CONFIG['DEFAULT_DISABLED_PANELS']: +        if 'debug_toolbar.panels.redirects.RedirectsPanel' \ +                in CONFIG['DEFAULT_DISABLED_PANELS']:              # RedirectsPanel should be enabled -            CONFIG['DEFAULT_DISABLED_PANELS'] = [ -                panel for panel in CONFIG['DEFAULT_DISABLED_PANELS'] -                if panel != "RedirectsPanel" -            ] -    elif not 'RedirectsPanel' in CONFIG['DEFAULT_DISABLED_PANELS']: +            try: +                CONFIG['DEFAULT_DISABLED_PANELS'].remove( +                    'debug_toolbar.panels.redirects.RedirectsPanel' +                ) +            except KeyError: +                # We wanted to remove it, but it didn't exist. This is fine +                pass +    elif not 'debug_toolbar.panels.redirects.RedirectsPanel' \ +            in CONFIG['DEFAULT_DISABLED_PANELS']:          # RedirectsPanel should be disabled -        CONFIG['DEFAULT_DISABLED_PANELS'].append('RedirectsPanel') +        CONFIG['DEFAULT_DISABLED_PANELS'].add( +            'debug_toolbar.panels.redirects.RedirectsPanel' +        )  PATCH_SETTINGS = getattr(settings, 'DEBUG_TOOLBAR_PATCH_SETTINGS', settings.DEBUG) diff --git a/docs/configuration.rst b/docs/configuration.rst index 4cb94f0..972d9ac 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -59,10 +59,10 @@ Toolbar options  * ``DEFAULT_DISABLED_PANELS`` -  Default: ``('RedirectsPanel', )`` +  Default: ``{'debug_toolbar.panels.redirects.RedirectsPanel'}`` -  A collection of panel class names that are disabled (but still displayed) -  by default. +  This setting is a set of the full Python paths to each panel that you +  want disabled (but still displayed) by default.  * ``INSERT_BEFORE`` | 
