Point to save(commit=False) in the "subset of fields" note
I think it might be useful to point to the save(commit=False) feature of form_for_model/instance in the "subset of fields" discussion. A common scenario is when a model has a ForeignKey relation to a User object. The webmaster doesn't want to expose the User field but rather add it in after receiving the form. This field is usually required and throws an error when using save() without commit=False.
http://www.djangoproject.com/documentation/newforms/#using-a-subset-of-fields-on-the-form
Change History
(9)
Needs documentation: |
set
|
Owner: |
changed from nobody to Philippe Raoult
|
Triage Stage: |
Unreviewed → Accepted
|
Has patch: |
set
|
Needs documentation: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Keywords: |
sprintsept14 added
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
There is already a note saying that fields not in the 'fields' argument of form_for_model should have default values or allowed to be Null. But it is possible to add a value before the save() and an exemple of that should be provided. Will do after me shower :)