Opened 9 years ago

Closed 9 years ago

#5364 closed (fixed)

Point to save(commit=False) in the "subset of fields" note

Reported by: anonymous Owned by: Philippe Raoult
Component: Documentation Version: master
Severity: Keywords: minor, sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

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

Attachments (4)

5364.diff (1.1 KB) - added by Philippe Raoult 9 years ago.
modified the doc accordingly
5364.2.diff (1.1 KB) - added by Philippe Raoult 9 years ago.
modified the doc accordingly, with input from #django-sprint
5364.3.diff (1.2 KB) - added by Philippe Raoult 9 years ago.
modified the doc accordingly, with input from #django-sprint
5364.4.diff (1.2 KB) - added by Philippe Raoult 9 years ago.
one more typo :)

Download all attachments as: .zip

Change History (9)

comment:1 Changed 9 years ago by Philippe Raoult

Needs documentation: set
Owner: changed from nobody to Philippe Raoult
Triage Stage: UnreviewedAccepted

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 :)

Changed 9 years ago by Philippe Raoult

Attachment: 5364.diff added

modified the doc accordingly

comment:2 Changed 9 years ago by Philippe Raoult

Has patch: set
Needs documentation: unset
Triage Stage: AcceptedReady for checkin

Changed 9 years ago by Philippe Raoult

Attachment: 5364.2.diff added

modified the doc accordingly, with input from #django-sprint

Changed 9 years ago by Philippe Raoult

Attachment: 5364.3.diff added

modified the doc accordingly, with input from #django-sprint

comment:3 Changed 9 years ago by Philippe Raoult

Status: newassigned

Changed 9 years ago by Philippe Raoult

Attachment: 5364.4.diff added

one more typo :)

comment:4 Changed 9 years ago by George Vilches <gav@…>

Keywords: sprintsept14 added

comment:5 Changed 9 years ago by Russell Keith-Magee

Resolution: fixed
Status: assignedclosed

(In [6409]) Fixed #5364 -- Clarified the warning regarding saving form_for_model forms with missing fields. Thanks to PhilR for the initial draft.

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