BaseInlineFormSet.add_fields adds multiple InlineForeignKeyFields
|Reported by:||Raumkraut||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When a formset object has its forms iterated over, the _construct_form(...) method calls self.add_fields(...) against each form in the set.
However, for a BaseInlineFormSet, the add_fields implementation creates an InlineForeignKeyField, and appends it to form._meta.fields. It does this for each form, and since form._meta is a class attribute, it ends up with multiple duplicate InlineForeignKeyField instances.
This doesn't appear to be normally evidenced in any usual output, since all the generated FK fields have the same name, so overwrite each other in name-keyed dictionaries of the fields.
Tested on the latest stable/1.6.x branch
Change History (8)
comment:1 in reply to: ↑ description Changed 3 years ago by Raumkraut
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset