Opened 13 years ago
Closed 13 years ago
#20107 closed Uncategorized (invalid)
Error in example for "Using initial data with a formset"
| Reported by: | anteater_sa | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 1.5 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
https://docs.djangoproject.com/en/1.5/topics/forms/formsets/#using-initial-data-with-a-formset
In the docs the initial dict is wrapped in a list which causes an error in Django 1.5, should be:
>>> ArticleFormSet = formset_factory(ArticleForm, extra=2)
>>> formset = ArticleFormSet(initial={
... 'title': u'Django is now open source',
... 'pub_date': datetime.date.today(),
... })
Note:
See TracTickets
for help on using tickets.
When passing initial data to a
FormSetinstance it's expected to be alistofdicts in order to specify initial data for individual forms.Formon the other hand accept initial as adict.See TicketClosingReasons/UseSupportChannels for more details.