The use of "Instance" in "Creating Forms from Models" is confusing.
|Reported by:||ElfSternberg||Owned by:||Jacob|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (9)
comment:1 Changed 8 years ago by
|milestone:||1.0.3 → 1.1|
|Patch needs improvement:||unset|