Code

#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(),
... })

Attachments (0)

Change History (1)

comment:1 Changed 16 months ago by charettes

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

When passing initial data to a FormSet instance it's expected to be a list of dicts in order to specify initial data for individual forms.

Form on the other hand accept initial as a dict.

See TicketClosingReasons/UseSupportChannels for more details.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.