summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorLuke Plant <L.Plant.98@cantab.net>2011-03-10 18:42:24 +0000
committerLuke Plant <L.Plant.98@cantab.net>2011-03-10 18:42:24 +0000
commite9d27639470d2e76ce51a2522aedc69ff912de3e (patch)
tree5d1b32374640fbe2124b5f362542bc04b3e98aa8 /django
parent3349b95db67440cd2bcd199578232e93d0e1b88c (diff)
Fixed #15572 - include with "only" option discards context properties (such as autoescape)
Thanks to dfoerster for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15795 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/template/context.py8
-rw-r--r--django/template/loader_tags.py2
2 files changed, 9 insertions, 1 deletions
diff --git a/django/template/context.py b/django/template/context.py
index 1c8b7dacd9..bcfaa3bf9e 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -99,6 +99,14 @@ class Context(BaseContext):
self.dicts.append(other_dict)
return other_dict
+ def new(self, values=None):
+ """
+ Returns a new Context with the same 'autoescape' value etc, but with
+ only the values given in 'values' stored.
+ """
+ return self.__class__(dict_=values, autoescape=self.autoescape,
+ current_app=self.current_app, use_l10n=self.use_l10n)
+
class RenderContext(BaseContext):
"""
A stack container for storing Template state.
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index 70096aafee..e289ef0d9e 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -136,7 +136,7 @@ class BaseIncludeNode(Node):
values = dict([(name, var.resolve(context)) for name, var
in self.extra_context.iteritems()])
if self.isolated_context:
- return template.render(Context(values))
+ return template.render(context.new(values))
context.update(values)
output = template.render(context)
context.pop()