summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorKeshav Kumar <https://github.com/keshav2212>2020-02-02 22:18:07 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-02-18 06:56:05 +0100
commitf37d548ede290690589e86b892c4f106e2a8e1bc (patch)
tree693f0ac6a43a19daf06c5826d32f51107e1e71b1 /django
parent86908785076b2bbc31b908781da6b6ad1779b18b (diff)
Fixed #20995 -- Added support for iterables of template names to {% include %} template tag.
Thanks Adam Johnson for the review.
Diffstat (limited to 'django')
-rw-r--r--django/template/loader_tags.py10
1 files changed, 7 insertions, 3 deletions
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'):