Opened 8 years ago

Closed 8 years ago

#9171 closed (fixed)

must pass `list` not `tuple` as `exclude` (as seen in docs) to `inlineformset_factory`.

Reported by: Tai Lee Owned by: nobody
Component: Forms Version: master
Severity: Keywords: inlineformset_factory exclude
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If the exclude argument is not None but is also not list an exception will be raised as we try to append the foreign key field. Patch simply calls list() on exclude to allow any iterable to be passed in, similar to ChoiceField._set_choices.

Attachments (2)

9171-inlineformset_factory-r9082.diff (876 bytes) - added by Tai Lee 8 years ago.
Added regression test that fails before and passes after patch is applied.
9171-inlineformset_factory-r9082.2.diff (2.2 KB) - added by Tai Lee 8 years ago.
Also fix ModelAdmin and InlineModelAdmin to allow a tuple for exclude.

Download all attachments as: .zip

Change History (4)

Changed 8 years ago by Tai Lee

Added regression test that fails before and passes after patch is applied.

comment:1 Changed 8 years ago by Brian Rosner

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

Changed 8 years ago by Tai Lee

Also fix ModelAdmin and InlineModelAdmin to allow a tuple for exclude.

comment:2 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [9086]) Fixed #9171 -- Fixed a few places where we were assuming lists instead of
generic sequences in ModelForm structures. Patch from mrmachine.

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