Opened 8 years ago

Closed 8 years ago

#26537 closed Bug (duplicate)

BaseInlineFormSet Adds N Entries to form._meta.fields For FK

Reported by: David Sanders Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently BaseInlineFormSet appends the FK name for the formset to the fields for the form Meta every time add_fields runs, so with you end up with N fields where N - 1 are duplicates. As each form is instantiated it'll see a different version of the list.

Example based on tests/inline_formsets/tests.py:

>>> poet = Poet.objects.create(name='test')
>>> poet.poem_set.create(name='first test poem')
>>> poet.poem_set.create(name='second test poem')
>>> poet.poem_set.create(name='third test poem')
>>> PoemFormSet = inlineformset_factory(Poet, Poem, fields=('name',), extra=0)
>>> formset = PoemFormSet(None, instance=poet)
>>> PoemFormSet.form._meta.fields
['name', 'poet', 'poet', 'poet']

Change History (3)

comment:1 by David Sanders, 8 years ago

Submitted PR #6503.

comment:2 by David Sanders, 8 years ago

Type: UncategorizedBug

comment:3 by Tim Graham, 8 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #21332

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