File tree Expand file tree Collapse file tree 5 files changed +57
-0
lines changed Expand file tree Collapse file tree 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):
2323 gzip_index = None
2424 debug_toolbar_indexes = []
2525
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+
2640 # If old style MIDDLEWARE_CLASSES is being used, report an error.
2741 if settings .is_overridden ("MIDDLEWARE_CLASSES" ):
2842 errors .append (
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ Next version
99 ``django.core.caches `` as a whole. The ``middleware.cache `` is still
1010 being patched as a whole in order to attempt to catch any cache
1111 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 ``.
1214
1315
14163.2.2 (2021-08-14)
Original file line number Diff line number Diff line change @@ -14,3 +14,5 @@ Debug Toolbar setup and configuration:
1414* **debug_toolbar.W004 **: ``debug_toolbar `` is incompatible with
1515 ``MIDDLEWARE_CLASSES `` setting.
1616* **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
3737
3838 STATIC_URL = '/static/'
3939
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+
4045If you're upgrading from a previous version, you should review the
4146:doc: `change log <changes >` and look for specific upgrade instructions.
4247
Original file line number Diff line number Diff line change @@ -122,3 +122,37 @@ def test_panels_is_empty(self):
122122 )
123123 ],
124124 )
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