From e9d27639470d2e76ce51a2522aedc69ff912de3e Mon Sep 17 00:00:00 2001 From: Luke Plant Date: Thu, 10 Mar 2011 18:42:24 +0000 Subject: 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 --- django/template/context.py | 8 ++++++++ django/template/loader_tags.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'django') 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() -- cgit v1.3