Opened 9 years ago
Closed 9 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']
Note:
See TracTickets
for help on using tickets.
Submitted PR #6503.