Opened 18 years ago

Closed 18 years ago

#3635 closed (fixed)

KeyError in newforms.models.save_instance()

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

Description

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@… 18 years ago.

Download all attachments as: .zip

Change History (5)

by ludo@…, 18 years ago

Attachment: models.diff added

comment:1 by ludo@…, 18 years ago

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

comment:2 by ludo@…, 18 years ago

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

comment:3 by Simon G. <dev@…>, 18 years ago

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

comment:4 by Malcolm Tredinnick, 18 years ago

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