1
0
mirror of https://github.com/django/django.git synced 2025-10-29 16:46:11 +00:00

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
This commit is contained in:
Luke Plant
2011-03-10 18:42:24 +00:00
parent 3349b95db6
commit e9d2763947
3 changed files with 13 additions and 1 deletions

View File

@@ -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.

View File

@@ -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()