[Django] #36995: Improve KeyError message in Form.__getitem__

3 views
Skip to first unread message

Django

unread,
Mar 20, 2026, 10:07:50 AM (16 hours ago) Mar 20
to django-...@googlegroups.com
#36995: Improve KeyError message in Form.__getitem__
-----------------------+-----------------------------------------
Reporter: shiva | Type: Uncategorized
Status: new | Component: Uncategorized
Version: 6.0 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------+-----------------------------------------
Currently, Form.__getitem__ raises a KeyError with a message that may be
unclear.

Proposed improvement:
Make the error message more descriptive by explicitly stating that the
field is not found in the form and listing available fields.

I have a working patch with updated tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/36995>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 20, 2026, 1:25:42 PM (13 hours ago) Mar 20
to django-...@googlegroups.com
#36995: Improve KeyError message in Form.__getitem__
-------------------------------+--------------------------------------
Reporter: shiva | Owner: (none)
Type: Uncategorized | Status: closed
Component: Uncategorized | Version: 6.0
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Simon Charette):

* resolution: => invalid
* status: new => closed

Comment:

> Currently, Form.getitem raises a KeyError with a message that may be
unclear.

You have not explained ''how'' or in which context this might be case so
it's unclear what ''problem'' you are trying to solve here.
--
Ticket URL: <https://code.djangoproject.com/ticket/36995#comment:1>
Reply all
Reply to author
Forward
0 new messages