Opened 6 years ago

Closed 6 years ago

Last modified 3 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 adurdin 6 years ago.
Docs patch

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by Alex

  • milestone changed from 1.0.3 to 1.1
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 6 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by adurdin

Docs patch

comment:3 Changed 6 years ago by adurdin

  • Triage Stage changed from Accepted to Ready 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 6 years ago by jacob

  • Owner changed from nobody to jacob
  • Status changed from new to assigned

comment:5 Changed 6 years ago by ramiro

  • Has patch set

comment:6 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from assigned to closed

(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 6 years ago by russellm

(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 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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