mirror of https://github.com/django/django.git
Fixed #21460 -- Reenabled proper template precedence in find_template
Refs #20806. Thanks Unai Zalakain for the review.
This commit is contained in:
parent
d6cc37d601
commit
3ac823fc5b
1
AUTHORS
1
AUTHORS
|
@ -420,6 +420,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
mark@junklight.com
|
mark@junklight.com
|
||||||
Orestis Markou <orestis@orestis.gr>
|
Orestis Markou <orestis@orestis.gr>
|
||||||
Andrés Torres Marroquín <andres.torres.marroquin@gmail.com>
|
Andrés Torres Marroquín <andres.torres.marroquin@gmail.com>
|
||||||
|
Pablo Martín <goinnn@gmail.com>
|
||||||
Takashi Matsuo <matsuo.takashi@gmail.com>
|
Takashi Matsuo <matsuo.takashi@gmail.com>
|
||||||
Zlatko Mašek <zlatko.masek@gmail.com>
|
Zlatko Mašek <zlatko.masek@gmail.com>
|
||||||
Yasushi Masuda <whosaysni@gmail.com>
|
Yasushi Masuda <whosaysni@gmail.com>
|
||||||
|
|
|
@ -53,6 +53,7 @@ class Loader(BaseLoader):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
result = (template, make_origin(display_name, loader, name, dirs))
|
result = (template, make_origin(display_name, loader, name, dirs))
|
||||||
|
break
|
||||||
self.find_template_cache[key] = result
|
self.find_template_cache[key] = result
|
||||||
if result:
|
if result:
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
no priority
|
|
@ -189,3 +189,33 @@ class TemplateDirsOverrideTest(unittest.TestCase):
|
||||||
for dirs in self.dirs_iter:
|
for dirs in self.dirs_iter:
|
||||||
template = loader.select_template(['test_dirs.html'], dirs=dirs)
|
template = loader.select_template(['test_dirs.html'], dirs=dirs)
|
||||||
self.assertEqual(template.render(Context({})), 'spam eggs\n')
|
self.assertEqual(template.render(Context({})), 'spam eggs\n')
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
TEMPLATE_LOADERS=(
|
||||||
|
('django.template.loaders.cached.Loader', (
|
||||||
|
'django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',
|
||||||
|
)),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
class PriorityCacheLoader(TestCase):
|
||||||
|
def test_basic(self):
|
||||||
|
"""
|
||||||
|
Check that the order of template loader works. Refs #21460.
|
||||||
|
"""
|
||||||
|
t1, name = loader.find_template('priority/foo.html')
|
||||||
|
self.assertEqual(t1.render(Context({})), 'priority\n')
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(
|
||||||
|
TEMPLATE_LOADERS=('django.template.loaders.filesystem.Loader',
|
||||||
|
'django.template.loaders.app_directories.Loader',),
|
||||||
|
)
|
||||||
|
class PriorityLoader(TestCase):
|
||||||
|
def test_basic(self):
|
||||||
|
"""
|
||||||
|
Check that the order of template loader works. Refs #21460.
|
||||||
|
"""
|
||||||
|
t1, name = loader.find_template('priority/foo.html')
|
||||||
|
self.assertEqual(t1.render(Context({})), 'priority\n')
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
priority
|
Loading…
Reference in New Issue