Fixed #32901 -- Optimized BaseForm.__getitem__().
This commit is contained in:
parent
2231429991
commit
edde2a0699
|
@ -149,6 +149,10 @@ class BaseForm:
|
||||||
|
|
||||||
def __getitem__(self, name):
|
def __getitem__(self, name):
|
||||||
"""Return a BoundField with the given name."""
|
"""Return a BoundField with the given name."""
|
||||||
|
try:
|
||||||
|
return self._bound_fields_cache[name]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
try:
|
try:
|
||||||
field = self.fields[name]
|
field = self.fields[name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -159,9 +163,9 @@ class BaseForm:
|
||||||
', '.join(sorted(self.fields)),
|
', '.join(sorted(self.fields)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if name not in self._bound_fields_cache:
|
bound_field = field.get_bound_field(self, name)
|
||||||
self._bound_fields_cache[name] = field.get_bound_field(self, name)
|
self._bound_fields_cache[name] = bound_field
|
||||||
return self._bound_fields_cache[name]
|
return bound_field
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def errors(self):
|
def errors(self):
|
||||||
|
|
Loading…
Reference in New Issue