Opened 17 years ago

Closed 16 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: dev
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: no UI/UX: no

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 17 years ago.
modified the doc accordingly
5364.2.diff (1.1 KB ) - added by Philippe Raoult 17 years ago.
modified the doc accordingly, with input from #django-sprint
5364.3.diff (1.2 KB ) - added by Philippe Raoult 17 years ago.
modified the doc accordingly, with input from #django-sprint
5364.4.diff (1.2 KB ) - added by Philippe Raoult 17 years ago.
one more typo :)

Download all attachments as: .zip

Change History (9)

comment:1 by Philippe Raoult, 17 years ago

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

by Philippe Raoult, 17 years ago

Attachment: 5364.diff added

modified the doc accordingly

comment:2 by Philippe Raoult, 17 years ago

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

by Philippe Raoult, 17 years ago

Attachment: 5364.2.diff added

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

by Philippe Raoult, 17 years ago

Attachment: 5364.3.diff added

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

comment:3 by Philippe Raoult, 17 years ago

Status: newassigned

by Philippe Raoult, 17 years ago

Attachment: 5364.4.diff added

one more typo :)

comment:4 by George Vilches <gav@…>, 17 years ago

Keywords: sprintsept14 added

comment:5 by Russell Keith-Magee, 16 years ago

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