Opened 4 years ago

Closed 4 years ago

#31588 closed Cleanup/optimization (invalid)

Unclear behaviour for ModelForms

Reported by: Vladislav Owned by: nobody
Component: Forms Version: 3.0
Severity: Normal Keywords: forms
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I think it's very often task to add nessasary info to ModelForm before .save() and i suppose this must have official decision, not this workaround like answers in ticket:

https://stackoverflow.com/questions/17126983/add-data-to-modelform-object-before-saving

Change History (1)

comment:1 by Carlton Gibson, 4 years ago

Resolution: invalid
Status: newclosed

Hi. Thanks for the report.

The official decision, the recommended way of doing it is to call save() with commit=False, then make your modifications before saving the instance finally.
This is documented in the save method docs. See the example there of modifying an author in this way.

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