#30917 closed Cleanup/optimization (fixed)
Clarify Formset documentation.
Reported by: | Ken Whitesell | Owned by: | Ken Whitesell |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Normal | Keywords: | Formset |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I believe the documentation for formsets is either misleading or possibly
incorrect.
From the existing documentation at
https://docs.djangoproject.com/en/2.2/topics/forms/formsets/
You might want to allow the user to create several articles at once. To create a formset out of an ArticleForm you would do: >>> from django.forms import formset_factory >>> ArticleFormSet = formset_factory(ArticleForm) You now have created a formset named ArticleFormSet.
It's my understanding that *at this point* you have not yet created a formset.
What you have done is create a formset class, from which you can create
instances of formsets.
It's not until you execute this line:
>>> formset = ArticleFormSet()
that you have actually created the formset.
By analogy, consider the detail provided for both Models and Forms.
On the page https://docs.djangoproject.com/en/2.2/ref/models/instances/
it is specified that "To create a new instance of a model, instantiate it like
any other Python class:"
Likewise, with Forms, at https://docs.djangoproject.com/en/2.2/ref/forms/api/
it states: "To create an unbound Form instance, simply instantiate the class:"
In both these cases, the distinction is made that there's a fundamental
difference between creating the Model and Form classes, and creating the
instances of those classes.
I believe the same distinction should be made with reference to Formsets,
making it explicitly clear that the formset_factory function creates a
class, and the class needs to be instantiated to create the instances to
be used within a page.
Change History (7)
comment:1 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 5 years ago
Has patch: | set |
---|
comment:3 by , 5 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Type: | Bug → Cleanup/optimization |
comment:4 by , 5 years ago
Summary: | Formset documentation → Clarify Formset documentation. |
---|
PR.