summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorPreston Timmons <prestontimmons@gmail.com>2015-03-11 11:00:17 -0500
committerTim Graham <timograham@gmail.com>2015-03-16 13:13:02 -0400
commit388e79e9fcbf689d5708134534e55d176cfbcee3 (patch)
tree8a0e1ae3570f4f3ca59ed4cfa55c7e747cd3dba5 /django
parent4d9414098bd98aacd241827a01f6ad2dff71f113 (diff)
Fixed #24493 -- Added BaseContext.setdefault()
Diffstat (limited to 'django')
-rw-r--r--django/template/context.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/django/template/context.py b/django/template/context.py
index af4fb8853b..2c30181927 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -89,6 +89,13 @@ class BaseContext(object):
return d[key]
return otherwise
+ def setdefault(self, key, default=None):
+ try:
+ return self[key]
+ except KeyError:
+ self[key] = default
+ return default
+
def new(self, values=None):
"""
Returns a new context with the same properties, but with only the