From f37d548ede290690589e86b892c4f106e2a8e1bc Mon Sep 17 00:00:00 2001 From: Keshav Kumar Date: Sun, 2 Feb 2020 22:18:07 +0530 Subject: Fixed #20995 -- Added support for iterables of template names to {% include %} template tag. Thanks Adam Johnson for the review. --- django/template/loader_tags.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'django') diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index 8fa3a14087..b96214cad1 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -168,12 +168,16 @@ class IncludeNode(Node): template = self.template.resolve(context) # Does this quack like a Template? if not callable(getattr(template, 'render', None)): - # If not, try the cache and get_template(). - template_name = template + # If not, try the cache and select_template(). + template_name = template or () + if isinstance(template_name, str): + template_name = (template_name,) + else: + template_name = tuple(template_name) cache = context.render_context.dicts[0].setdefault(self, {}) template = cache.get(template_name) if template is None: - template = context.template.engine.get_template(template_name) + template = context.template.engine.select_template(template_name) cache[template_name] = template # Use the base.Template of a backends.django.Template. elif hasattr(template, 'template'): -- cgit v1.3