File tree 5 files changed +57
-0
lines changed
5 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,20 @@ def check_middleware(app_configs, **kwargs):
23
23
gzip_index = None
24
24
debug_toolbar_indexes = []
25
25
26
+ if all (not config .get ("APP_DIRS" , False ) for config in settings .TEMPLATES ):
27
+ errors .append (
28
+ Warning (
29
+ "At least one DjangoTemplates TEMPLATES configuration needs "
30
+ "to have APP_DIRS set to True." ,
31
+ hint = (
32
+ "Use APP_DIRS=True for at least one "
33
+ "django.template.backends.django.DjangoTemplates "
34
+ "backend configuration."
35
+ ),
36
+ id = "debug_toolbar.W006" ,
37
+ )
38
+ )
39
+
26
40
# If old style MIDDLEWARE_CLASSES is being used, report an error.
27
41
if settings .is_overridden ("MIDDLEWARE_CLASSES" ):
28
42
errors .append (
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ Next version
9
9
``django.core.caches `` as a whole. The ``middleware.cache `` is still
10
10
being patched as a whole in order to attempt to catch any cache
11
11
usages before ``enable_instrumentation `` is called.
12
+ * Add check ``W006 `` to warn that the toolbar is incompatible with
13
+ ``TEMPLATES `` settings configurations with ``APP_DIRS `` set to ``False ``.
12
14
13
15
14
16
3.2.2 (2021-08-14)
Original file line number Diff line number Diff line change @@ -14,3 +14,5 @@ Debug Toolbar setup and configuration:
14
14
* **debug_toolbar.W004 **: ``debug_toolbar `` is incompatible with
15
15
``MIDDLEWARE_CLASSES `` setting.
16
16
* **debug_toolbar.W005 **: Setting ``DEBUG_TOOLBAR_PANELS `` is empty.
17
+ * **debug_toolbar.W006 **: At least one ``DjangoTemplates `` ``TEMPLATES ``
18
+ configuration needs to have ``APP_DIRS `` set to ``True ``.
Original file line number Diff line number Diff line change @@ -37,6 +37,11 @@ Make sure that ``'django.contrib.staticfiles'`` is `set up properly
37
37
38
38
STATIC_URL = '/static/'
39
39
40
+ Make sure your ``TEMPLATES `` setting contains a ``DjangoTemplates `` backend
41
+ whose ``APP_DIRS `` options is set to ``True ``. It's in there by default, so
42
+ you'll only need to change this if you've changed that setting.
43
+
44
+
40
45
If you're upgrading from a previous version, you should review the
41
46
:doc: `change log <changes >` and look for specific upgrade instructions.
42
47
Original file line number Diff line number Diff line change @@ -122,3 +122,37 @@ def test_panels_is_empty(self):
122
122
)
123
123
],
124
124
)
125
+
126
+ @override_settings (
127
+ TEMPLATES = [
128
+ {
129
+ "BACKEND" : "django.template.backends.django.DjangoTemplates" ,
130
+ "APP_DIRS" : False ,
131
+ "OPTIONS" : {
132
+ "context_processors" : [
133
+ "django.template.context_processors.debug" ,
134
+ "django.template.context_processors.request" ,
135
+ "django.contrib.auth.context_processors.auth" ,
136
+ "django.contrib.messages.context_processors.messages" ,
137
+ ]
138
+ },
139
+ },
140
+ ]
141
+ )
142
+ def test_templates_is_using_app_dirs_false (self ):
143
+ errors = run_checks ()
144
+ self .assertEqual (
145
+ errors ,
146
+ [
147
+ Warning (
148
+ "At least one DjangoTemplates TEMPLATES configuration "
149
+ "needs to have APP_DIRS set to True." ,
150
+ hint = (
151
+ "Use APP_DIRS=True for at least one "
152
+ "django.template.backends.django.DjangoTemplates "
153
+ "backend configuration."
154
+ ),
155
+ id = "debug_toolbar.W006" ,
156
+ )
157
+ ],
158
+ )
You can’t perform that action at this time.
0 commit comments