Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10845 closed (fixed)

The use of "Instance" in "Creating Forms from Models" is confusing.

Reported by: ElfSternberg Owned by: Jacob
Component: Documentation Version: 1.0
Severity: Keywords: grammar
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In the section "Using a subset of fields on a form," the example contains the text:

instance = Instance(required_field='value')
form = InstanceForm(request.POST, instance=instance)

The use of "instance" here as the lvalue of Instance is a poor choice. For someone skimming through the article looking just for the syntax for a subset of fields on a form, and who may have missed the text earlier in the article about the instance keyword, this seems to imply that the keyword argument might be some lowercase variant of the Model name. I strongly suggest an alternative example:

example = Example(required_field='value')
form = ExampleForm(request.POST, instance=example)

Which would make it much more clear that "instance" is the kwarg, and the kwarg is not generated dynamically.

Attachments (1)

partial_modelform_note.diff (1.1 KB) - added by Andy Durdin 7 years ago.
Docs patch

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by Alex Gaynor

milestone: 1.0.31.1
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 7 years ago by Jacob

Triage Stage: UnreviewedAccepted

Changed 7 years ago by Andy Durdin

Attachment: partial_modelform_note.diff added

Docs patch

comment:3 Changed 7 years ago by Andy Durdin

Triage Stage: AcceptedReady for checkin

Rather than use the meaningless names "Example", I used the same Author models as used in the docs up to this point for clarity.

comment:4 Changed 7 years ago by Jacob

Owner: changed from nobody to Jacob
Status: newassigned

comment:5 Changed 7 years ago by Ramiro Morales

Has patch: set

comment:6 Changed 7 years ago by Russell Keith-Magee

Resolution: fixed
Status: assignedclosed

(In [10972]) Fixed #10845 -- Clarified the examples for using ModelForms with fields or exclude specified. Thanks to Andrew Durdin for the suggestion.

comment:7 Changed 7 years ago by Russell Keith-Magee

(In [10975]) [1.0.X] Fixed #10845 -- Clarified the examples for using ModelForms with fields or exclude specified. Thanks to Andrew Durdin for the suggestion.

Merge of r10972 from trunk.

comment:8 Changed 5 years ago by Jacob

milestone: 1.1

Milestone 1.1 deleted

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