@@ -43,6 +43,7 @@ def check_debug():
43
43
to do its work. Check that the setting is correct, and raise an exception
44
44
if it is not.
45
45
46
+ Returns True if the debug check was performed, False otherwise
46
47
"""
47
48
# The settings for templates changed in Django 1.8 from TEMPLATE_DEBUG to
48
49
# TEMPLATES[..]['debug']. Django 1.9 tolerated both forms, 1.10 insists on
@@ -51,14 +52,17 @@ def check_debug():
51
52
52
53
from django .conf import settings
53
54
55
+ if not settings .configured :
56
+ return False
57
+
54
58
try :
55
59
templates = getattr (settings , 'TEMPLATES' , [])
56
60
except ImproperlyConfigured :
57
61
# Maybe there are no settings at all. We are fine with this. Our
58
62
# code will need settings, but if this program we're in runs without
59
63
# settings, then it must be that it never uses templates, and our code
60
64
# will never try to use the settings anyway.
61
- return
65
+ return True
62
66
63
67
if templates :
64
68
for template_settings in templates :
@@ -75,6 +79,8 @@ def check_debug():
75
79
"Template debugging must be enabled in settings."
76
80
)
77
81
82
+ return True
83
+
78
84
79
85
if django .VERSION >= (1 , 9 ):
80
86
# Since we are grabbing at internal details, we have to adapt as they
@@ -151,8 +157,7 @@ def sys_info(self):
151
157
def file_tracer (self , filename ):
152
158
if filename .startswith (self .django_template_dir ):
153
159
if not self .debug_checked :
154
- check_debug ()
155
- self .debug_checked = True
160
+ self .debug_checked = check_debug ()
156
161
157
162
return self
158
163
return None
0 commit comments