diff options
| author | Alex Hill <alex@hill.net.au> | 2013-12-19 13:42:32 +0800 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2013-12-20 01:02:50 +0100 |
| commit | 832ab0dbaacf381d15445259f292d88175ff84f2 (patch) | |
| tree | 20239d25f377753cdde47a4c612332dcbe340776 /django | |
| parent | 23d9f517dc3ca31816bb8596f5a59f1ae44304ee (diff) | |
Fixed #21639 -- Implemented RenderContext.__getitem__
It's now consistent with RenderContext.get.
Diffstat (limited to 'django')
| -rw-r--r-- | django/template/context.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/django/template/context.py b/django/template/context.py index ba2c3d4d07..7a5ad161d4 100644 --- a/django/template/context.py +++ b/django/template/context.py @@ -145,11 +145,10 @@ class RenderContext(BaseContext): return key in self.dicts[-1] def get(self, key, otherwise=None): - d = self.dicts[-1] - if key in d: - return d[key] - return otherwise + return self.dicts[-1].get(key, otherwise) + def __getitem__(self, key): + return self.dicts[-1][key] # This is a function rather than module-level procedural code because we only # want it to execute if somebody uses RequestContext. |
