1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #24493 -- Added BaseContext.setdefault()

This commit is contained in:
Preston Timmons
2015-03-11 11:00:17 -05:00
committed by Tim Graham
parent 4d9414098b
commit 388e79e9fc
4 changed files with 28 additions and 0 deletions

View File

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