KeyError in newforms.models.save_instance()
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.
Change History
(5)
| Summary: |
KeyError in newforms.models.save_instance() [patch] → [patch] KeyError in newforms.models.save_instance()
|
| Has patch: |
set
|
| Summary: |
[patch] KeyError in newforms.models.save_instance() → KeyError in newforms.models.save_instance()
|
| Triage Stage: |
Unreviewed → Ready for checkin
|
| Resolution: |
→ fixed
|
| Status: |
new → closed
|
Ugh, not
form_for_model(inst, form=CustomForm)butform_for_instance(inst, form=CustomForm). Newforms are melting my brain...