Opened 14 years ago
Closed 14 years ago
#16467 closed Cleanup/optimization (fixed)
Little typo in the Formset docu
| Reported by: | Owned by: | teraom | |
|---|---|---|---|
| Component: | Documentation | Version: | 1.3 |
| Severity: | Normal | Keywords: | form inital value |
| 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
Is it possible that the example regarding "Using initial data with a formset" has too many brackets?
>>> formset = ArticleFormSet(initial=[
... {'title': u'Django is now open source',
... 'pub_date': datetime.date.today()},
... ])
could it be ... (above did knot work for me)
>>> formset = ArticleFormSet(initial={
... 'title': u'Django is now open source',
... 'pub_date': datetime.date.today(),
... })
With the inital example I get the error msg:
dictionary update sequence element #0 has length 5; 2 is required
Just a thought.
Best regards,
Hannes
Attachments (1)
Change History (8)
comment:1 by , 14 years ago
| Component: | Forms → Documentation |
|---|---|
| Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
by , 14 years ago
| Attachment: | formset_example.diff added |
|---|
comment:3 by , 14 years ago
| Has patch: | set |
|---|
comment:4 by , 14 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:5 by , 14 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
comment:6 by , 14 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
The documentation was correct as written. Initial should be an array of dictionaries where the dictionaries are used for successive forms.
If you look at https://code.djangoproject.com/browser/django/trunk/django/forms/formsets.py#L110 to construct the i'th form instance the initial paramater pulls self.initial[i]
In [16564]: