mirror of
https://github.com/django/django.git
synced 2025-11-02 21:03:53 +00:00
Fixed #25788 -- Enabled the cached template loader if debug is False.
This commit is contained in:
parent
2ced2f785d
commit
277fe2e8f2
6 changed files with 55 additions and 13 deletions
|
|
@ -130,3 +130,18 @@ class DjangoTemplatesTests(TemplateStringsTests):
|
|||
engines['django'].from_string('Hello, {{ name }}').render({'name': 'Bob & Jim'}),
|
||||
'Hello, Bob & Jim'
|
||||
)
|
||||
|
||||
default_loaders = [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
]
|
||||
|
||||
@override_settings(DEBUG=False)
|
||||
def test_non_debug_default_template_loaders(self):
|
||||
engine = DjangoTemplates({'DIRS': [], 'APP_DIRS': True, 'NAME': 'django', 'OPTIONS': {}})
|
||||
self.assertEqual(engine.engine.loaders, [('django.template.loaders.cached.Loader', self.default_loaders)])
|
||||
|
||||
@override_settings(DEBUG=True)
|
||||
def test_debug_default_template_loaders(self):
|
||||
engine = DjangoTemplates({'DIRS': [], 'APP_DIRS': True, 'NAME': 'django', 'OPTIONS': {}})
|
||||
self.assertEqual(engine.engine.loaders, self.default_loaders)
|
||||
|
|
|
|||
|
|
@ -11,11 +11,14 @@ from django.test.client import RequestFactory
|
|||
'APP_DIRS': True,
|
||||
}, {
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.request',
|
||||
],
|
||||
'loaders': [
|
||||
'django.template.loaders.filesystem.Loader',
|
||||
'django.template.loaders.app_directories.Loader',
|
||||
]
|
||||
},
|
||||
}])
|
||||
class TemplateLoaderTests(SimpleTestCase):
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ class FileSystemLoaderTests(SimpleTestCase):
|
|||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.engine = Engine(dirs=[TEMPLATE_DIR])
|
||||
cls.engine = Engine(dirs=[TEMPLATE_DIR], loaders=['django.template.loaders.filesystem.Loader'])
|
||||
super(FileSystemLoaderTests, cls).setUpClass()
|
||||
|
||||
@contextmanager
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue