summaryrefslogtreecommitdiff
path: root/django/template/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/template/context.py')
-rw-r--r--django/template/context.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/django/template/context.py b/django/template/context.py
index ba23e95ab7..59650b05fe 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -35,7 +35,7 @@ class Context(object):
def __getitem__(self, key):
"Get a variable's value, starting at the current context and going upward"
for d in self.dicts:
- if d.has_key(key):
+ if key in d:
return d[key]
raise KeyError(key)
@@ -45,13 +45,16 @@ class Context(object):
def has_key(self, key):
for d in self.dicts:
- if d.has_key(key):
+ if key in d:
return True
return False
+ def __contains__(self, key):
+ return self.has_key(key)
+
def get(self, key, otherwise=None):
for d in self.dicts:
- if d.has_key(key):
+ if key in d:
return d[key]
return otherwise