aboutsummaryrefslogtreecommitdiffstats
path: root/debug_toolbar
diff options
context:
space:
mode:
Diffstat (limited to 'debug_toolbar')
-rw-r--r--debug_toolbar/middleware.py7
-rw-r--r--debug_toolbar/settings.py7
2 files changed, 7 insertions, 7 deletions
diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py
index b7114af..b58f588 100644
--- a/debug_toolbar/middleware.py
+++ b/debug_toolbar/middleware.py
@@ -8,6 +8,7 @@ import threading
from django.conf import settings
from django.utils.encoding import force_text
+from django.utils.importlib import import_module
from debug_toolbar.toolbar import DebugToolbar
from debug_toolbar import settings as dt_settings
@@ -38,7 +39,11 @@ class DebugToolbarMiddleware(object):
debug_toolbars = {}
def process_request(self, request):
- if not dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK'](request):
+ func_path = dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK']
+ # Replace this with import_by_path in Django >= 1.6.
+ mod_path, func_name = func_path.rsplit('.', 1)
+ show_toolbar = getattr(import_module(mod_path), func_name)
+ if not show_toolbar(request):
return
response = None
toolbar = DebugToolbar(request)
diff --git a/debug_toolbar/settings.py b/debug_toolbar/settings.py
index 8534c2a..022fb8a 100644
--- a/debug_toolbar/settings.py
+++ b/debug_toolbar/settings.py
@@ -62,12 +62,7 @@ if 'TAG' in USER_CONFIG:
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:
+if not isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types):
warnings.warn(
"SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your "
"DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)