Opened 10 years ago

Closed 10 years ago

#3635 closed (fixed)

KeyError in newforms.models.save_instance()

Reported by: ludo@… Owned by: Adrian Holovaty
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


A KeyError is raised by when saving a custom form (created with form_for_model(inst, form=CustomForm) if it has less fields than the model it refers to. As custom forms are a handy way to expose only a subset of the available fields, checking for the field in the form's clean_data before setting its value in the model seems a good idea.

Attachments (1)

models.diff (1.0 KB) - added by ludo@… 10 years ago.

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by ludo@…

Attachment: models.diff added

comment:1 Changed 10 years ago by ludo@…

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

Ugh, not form_for_model(inst, form=CustomForm) but form_for_instance(inst, form=CustomForm). Newforms are melting my brain...

comment:2 Changed 10 years ago by ludo@…

Summary: KeyError in newforms.models.save_instance() [patch][patch] KeyError in newforms.models.save_instance()

comment:3 Changed 10 years ago by Simon G. <dev@…>

Has patch: set
Summary: [patch] KeyError in newforms.models.save_instance()KeyError in newforms.models.save_instance()
Triage Stage: UnreviewedReady for checkin

comment:4 Changed 10 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [4878]) Fixed #3635 -- Fixed KeyError problem in newforms.model.save_instance().
Thanks, ludo@….

Note: See TracTickets for help on using tickets.
Back to Top