Skip to content

Commit 6b0d32f

Browse files
committed
Fix cyclic import issues in db2de5b.
1 parent 1c1b442 commit 6b0d32f

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

debug_toolbar/middleware.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from django.conf import settings
1010
from django.utils.encoding import force_text
11+
from django.utils.importlib import import_module
1112

1213
from debug_toolbar.toolbar import DebugToolbar
1314
from debug_toolbar import settings as dt_settings
@@ -38,7 +39,11 @@ class DebugToolbarMiddleware(object):
3839
debug_toolbars = {}
3940

4041
def process_request(self, request):
41-
if not dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK'](request):
42+
func_path = dt_settings.CONFIG['SHOW_TOOLBAR_CALLBACK']
43+
# Replace this with import_by_path in Django >= 1.6.
44+
mod_path, func_name = func_path.rsplit('.', 1)
45+
show_toolbar = getattr(import_module(mod_path), func_name)
46+
if not show_toolbar(request):
4247
return
4348
response = None
4449
toolbar = DebugToolbar(request)

debug_toolbar/settings.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@
6262

6363
CONFIG = CONFIG_DEFAULTS.copy()
6464
CONFIG.update(USER_CONFIG)
65-
if isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types):
66-
# Replace this with import_by_path in Django >= 1.6.
67-
mod_path, func_name = CONFIG['SHOW_TOOLBAR_CALLBACK'].rsplit('.', 1)
68-
mod = import_module(mod_path)
69-
CONFIG['SHOW_TOOLBAR_CALLBACK'] = getattr(mod, func_name)
70-
else:
65+
if not isinstance(CONFIG['SHOW_TOOLBAR_CALLBACK'], six.string_types):
7166
warnings.warn(
7267
"SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your "
7368
"DEBUG_TOOLBAR_CONFIG setting.", DeprecationWarning)

0 commit comments

Comments
 (0)