diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/context.py | 8 | ||||
| -rw-r--r-- | django/template/loader_tags.py | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/django/template/context.py b/django/template/context.py index 166f60fe75..7f0826c644 100644 --- a/django/template/context.py +++ b/django/template/context.py @@ -215,15 +215,17 @@ class RenderContext(BaseContext): return self.dicts[-1][key] @contextmanager - def push_state(self, template): + def push_state(self, template, isolated_context=True): initial = self.template self.template = template - self.push() + if isolated_context: + self.push() try: yield finally: self.template = initial - self.pop() + if isolated_context: + self.pop() class RequestContext(Context): diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index 4ff5ec4db5..020f2e412a 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -173,7 +173,8 @@ class ExtendsNode(Node): # Call Template._render explicitly so the parser context stays # the same. - return compiled_parent._render(context) + with context.render_context.push_state(compiled_parent, isolated_context=False): + return compiled_parent._render(context) class IncludeNode(Node): |
