mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #26502 -- Added choices to Form.__getitem__() KeyError message.
This commit is contained in:
@@ -140,7 +140,12 @@ class BaseForm(object):
|
||||
field = self.fields[name]
|
||||
except KeyError:
|
||||
raise KeyError(
|
||||
"Key %r not found in '%s'" % (name, self.__class__.__name__))
|
||||
"Key '%s' not found in '%s'. Choices are: %s." % (
|
||||
name,
|
||||
self.__class__.__name__,
|
||||
', '.join(sorted(f for f in self.fields)),
|
||||
)
|
||||
)
|
||||
if name not in self._bound_fields_cache:
|
||||
self._bound_fields_cache[name] = field.get_bound_field(self, name)
|
||||
return self._bound_fields_cache[name]
|
||||
|
||||
Reference in New Issue
Block a user