File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 8
8
9
9
from django .conf import settings
10
10
from django .utils .encoding import force_text
11
+ from django .utils .importlib import import_module
11
12
12
13
from debug_toolbar .toolbar import DebugToolbar
13
14
from debug_toolbar import settings as dt_settings
@@ -38,7 +39,11 @@ class DebugToolbarMiddleware(object):
38
39
debug_toolbars = {}
39
40
40
41
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 ):
42
47
return
43
48
response = None
44
49
toolbar = DebugToolbar (request )
Original file line number Diff line number Diff line change 62
62
63
63
CONFIG = CONFIG_DEFAULTS .copy ()
64
64
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 ):
71
66
warnings .warn (
72
67
"SHOW_TOOLBAR_CALLBACK is now a dotted path. Update your "
73
68
"DEBUG_TOOLBAR_CONFIG setting." , DeprecationWarning )
You can’t perform that action at this time.
0 commit comments