diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-14 10:21:06 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-14 10:21:06 +0100 |
| commit | 47ee7b48adbcc0dafc3404034286c5fcbcd1cea6 (patch) | |
| tree | 88963887c1a5aaa265afa9e4733763d51f10fa36 /django | |
| parent | 18c0aaa9123579375294fcc4a8ee7e3530176b88 (diff) | |
Fixed #24338 -- Accepted Template wrapper in {% extends %}.
Explicitly checking for django.template.Template subclasses is
preferrable to duck-typing because both the django.template.Template and
django.template.backends.django.Template have a render() method.
Thanks spectras for the report.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/loader_tags.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index f1c08ee955..e6635258a7 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -1,7 +1,8 @@ from collections import defaultdict from django.template.base import ( - Library, Node, TemplateSyntaxError, TextNode, Variable, token_kwargs, + Library, Node, Template, TemplateSyntaxError, TextNode, Variable, + token_kwargs, ) from django.utils import six from django.utils.safestring import mark_safe @@ -100,8 +101,12 @@ class ExtendsNode(Node): error_msg += " Got this from the '%s' variable." %\ self.parent_name.token raise TemplateSyntaxError(error_msg) - if hasattr(parent, 'render'): - return parent # parent is a Template object + if isinstance(parent, Template): + # parent is a django.template.Template + return parent + if isinstance(getattr(parent, 'template', None), Template): + # parent is a django.template.backends.django.Template + return parent.template return context.engine.get_template(parent) def render(self, context): |
