diff options
Diffstat (limited to 'django/template/base.py')
| -rw-r--r-- | django/template/base.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/django/template/base.py b/django/template/base.py index 76f77fc793..0c57050313 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -202,19 +202,15 @@ class Template(object): def render(self, context): "Display stage -- can be called many times" - # Set context.template to the original template -- as opposed to - # extended or included templates -- during rendering. This may be - # used for accessing context.template.engine. - toplevel_render = context.template is None - if toplevel_render: - context.template = self context.render_context.push() try: - return self._render(context) + if context.template is None: + with context.bind_template(self): + return self._render(context) + else: + return self._render(context) finally: context.render_context.pop() - if toplevel_render: - context.template = None class Token(object): |
