Opened 8 years ago

Closed 8 years ago

#27281 closed Cleanup/optimization (duplicate)

can-delete: we don't use initial data

Reported by: Michael Owned by: nobody
Component: Documentation Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/1.10/topics/forms/formsets/#can-delete

>>> data = {
...     'form-TOTAL_FORMS': '3',
...     'form-INITIAL_FORMS': '2',
...     'form-MAX_NUM_FORMS': '',
...     'form-0-title': 'Article #1',
...     'form-0-pub_date': '2008-05-10',
...     'form-0-DELETE': 'on',
...     'form-1-title': 'Article #2',
...     'form-1-pub_date': '2008-05-11',
...     'form-1-DELETE': '',
...     'form-2-title': '',
...     'form-2-pub_date': '',
...     'form-2-DELETE': '',
... }

>>> formset = ArticleFormSet(data, initial=[
...     {'title': 'Article #1', 'pub_date': datetime.date(2008, 5, 10)},
...     {'title': 'Article #2', 'pub_date': datetime.date(2008, 5, 11)},
... ])

We don't use initial data here. It overburdens the documentation.

Offer: formset = ArticleFormSet(data)

Change History (1)

comment:1 by Tim Graham, 8 years ago

Resolution: duplicate
Status: newclosed

As noted in #27280, I'm not sure the suggestion is correct. Anyway, we can discuss it there and make this change as part of that ticket if I'm wrong.

Note: See TracTickets for help on using tickets.
Back to Top