mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #21639 -- Implemented RenderContext.__getitem__
It's now consistent with RenderContext.get.
This commit is contained in:
committed by
Baptiste Mispelon
parent
23d9f517dc
commit
832ab0dbaa
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user