BaseInlineFormSet.add_fields adds multiple InlineForeignKeyFields
|Reported by:||Raumkraut||Owned by:||nobody|
|Has patch:||no||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 (5)
comment:1 in reply to: ↑ description Changed 20 months ago by Raumkraut
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset