summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/templates/api.txt15
-rw-r--r--docs/releases/1.9.txt3
2 files changed, 18 insertions, 0 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index 077330f6ce..5e56eff1d4 100644
--- a/docs/ref/templates/api.txt
+++ b/docs/ref/templates/api.txt
@@ -497,6 +497,21 @@ the stack instead of an empty one.
>>> c['foo']
'first level'
+Like ``push()``, you can use ``update()`` as a context manager to ensure a
+matching ``pop()`` is called.
+
+ >>> c = Context()
+ >>> c['foo'] = 'first level'
+ >>> with c.update({'foo': 'second level'}):
+ ... c['foo']
+ 'second level'
+ >>> c['foo']
+ 'first level'
+
+.. versionadded:: 1.9
+
+ The ability to use ``update()`` as a context manager was added.
+
Using a ``Context`` as a stack comes in handy in :ref:`some custom template
tags <howto-writing-custom-template-tags>`.
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 47c2bc98bc..25da6978ba 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -211,6 +211,9 @@ Templates
* The :ttag:`firstof` template tag supports storing the output in a variable
using 'as'.
+* :meth:`Context.update() <django.template.Context.update>` can now be used as
+ a context manager.
+
Requests and Responses
^^^^^^^^^^^^^^^^^^^^^^