Skip to content

Commit d2ac8bb

Browse files
authored
Development: disable cached Loader on DEBUG=True (#10640)
On Django 4.1 the cached Loader is enabled on `DEBUG=True`. This commit reverts this behavior because it makes harder to work on the new templates. Closes readthedocs/readthedocs-corporate#1635
1 parent 4ddf876 commit d2ac8bb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

readthedocs/settings/base.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,22 @@ def TEMPLATES(self):
396396
os.path.dirname(readthedocsext.theme.__file__),
397397
'templates',
398398
))
399+
400+
# Disable ``cached.Loader`` on development
401+
# https://docs.djangoproject.com/en/4.2/ref/templates/api/#django.template.loaders.cached.Loader
402+
default_loaders = [
403+
"django.template.loaders.filesystem.Loader",
404+
"django.template.loaders.app_directories.Loader",
405+
]
406+
cached_loaders = [("django.template.loaders.cached.Loader", default_loaders)]
407+
399408
return [
400409
{
401410
'BACKEND': 'django.template.backends.django.DjangoTemplates',
402411
'DIRS': dirs,
403-
'APP_DIRS': True,
404412
'OPTIONS': {
405413
'debug': self.DEBUG,
414+
'loaders': default_loaders if self.DEBUG else cached_loaders,
406415
'context_processors': [
407416
'django.contrib.auth.context_processors.auth',
408417
'django.contrib.messages.context_processors.messages',

0 commit comments

Comments
 (0)