summaryrefslogtreecommitdiff
path: root/docs/ref/templates
diff options
context:
space:
mode:
authorChris Beaven <smileychris@gmail.com>2010-11-24 00:36:36 +0000
committerChris Beaven <smileychris@gmail.com>2010-11-24 00:36:36 +0000
commit4c519867904918d8cdf2ded91af3e87bd1c02664 (patch)
treecce69cb3712c2def60d1ffddd74d997ed6a8e7ed /docs/ref/templates
parentff7c243b4c1dcefb504b5b636b0631edfb5a46c2 (diff)
Fixes #3529 -- more explicit documentation about Context.update. Thanks for the patch, ggetzie.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14689 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/templates')
-rw-r--r--docs/ref/templates/api.txt16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt
index e02debe39b..44de4d9906 100644
--- a/docs/ref/templates/api.txt
+++ b/docs/ref/templates/api.txt
@@ -281,6 +281,22 @@ If you ``pop()`` too much, it'll raise
...
django.template.ContextPopException
+In addition to ``push()`` and ``pop()``, the ``Context``
+object also defines an ``update()`` method. This works like ``push()``
+but takes a dictionary as an argument and pushes that dictionary onto
+the stack instead of an empty one.
+
+ >>> c = Context()
+ >>> c['foo'] = 'first level'
+ >>> c.update({'foo': 'updated'})
+ {'foo': 'updated'}
+ >>> c['foo']
+ 'updated'
+ >>> c.pop()
+ {'foo': 'updated'}
+ >>> c['foo']
+ 'first level'
+
Using a ``Context`` as a stack comes in handy in some custom template tags, as
you'll see below.