diff options
| author | Aymeric Augustin | 2013-11-24 12:00:24 +0100 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-11-24 12:00:24 +0100 | 
| commit | db2de5b85ac1ae099b91bae402d21d6ea36ef306 (patch) | |
| tree | 40238c6a121bd5a37ee4e4519cd648ec36cfd46b /debug_toolbar/settings.py | |
| parent | 03fd1cc81c02a5462aeb4dbce0bfe8a2afdef43d (diff) | |
| download | django-debug-toolbar-db2de5b85ac1ae099b91bae402d21d6ea36ef306.tar.bz2 | |
Make SHOW_TOOLBAR_CALLBACK a dotted path.
Fix #473.
Diffstat (limited to 'debug_toolbar/settings.py')
| -rw-r--r-- | debug_toolbar/settings.py | 14 | 
1 files changed, 12 insertions, 2 deletions
| diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py index 5a58b6b..8534c2a 100644 --- a/debug_toolbar/settings.py +++ b/debug_toolbar/settings.py @@ -20,7 +20,7 @@ CONFIG_DEFAULTS = {      'RESULTS_STORE_SIZE': 10,      'ROOT_TAG_EXTRA_ATTRS': '',      'SHOW_COLLAPSED': False, -    'SHOW_TOOLBAR_CALLBACK': None, +    'SHOW_TOOLBAR_CALLBACK': 'debug_toolbar.middleware.show_toolbar',      # Panel options      'EXTRA_SIGNALS': [],      'ENABLE_STACKTRACES': True, @@ -36,7 +36,6 @@ CONFIG_DEFAULTS = {      'SQL_WARNING_THRESHOLD': 500,   # milliseconds  } -CONFIG = CONFIG_DEFAULTS.copy()  USER_CONFIG = getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {})  # Backward-compatibility for 1.0, remove in 2.0.  _RENAMED_CONFIG = { @@ -60,7 +59,18 @@ if 'TAG' in USER_CONFIG:          "TAG was replaced by INSERT_BEFORE. Update your "          "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)      USER_CONFIG['INSERT_BEFORE'] = '</%s>' % USER_CONFIG.pop('TAG') + +CONFIG = CONFIG_DEFAULTS.copy()  CONFIG.update(USER_CONFIG) +if isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types): +    # Replace this with import_by_path in Django >= 1.6. +    mod_path, func_name = CONFIG['SHOW_TOOLBAR_CALLBACK'].rsplit('.', 1) +    mod = import_module(mod_path) +    CONFIG['SHOW_TOOLBAR_CALLBACK'] = getattr(mod, func_name) +else: +    warnings.warn( +        "SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your " +        "DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)  PANELS_DEFAULTS = [ | 
