summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-04-14 09:10:33 -0400
committerTim Graham <timograham@gmail.com>2016-04-14 09:15:09 -0400
commit3cb63b0e473568cb5158d7a4f13cb7e1c9ee89f5 (patch)
treed22cdcaef191493225e7b458a44d057317400cb2 /django/forms
parent5c6d397956f405f5c3fee6dc42568386972b9fc2 (diff)
Refs #26502 -- Added choices to Form.__getitem__() KeyError message.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/forms.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/forms/forms.py b/django/forms/forms.py
index df382deda9..ac5cf12425 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -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]