Code

Opened 6 years ago

Closed 6 years ago

#9171 closed (fixed)

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

Reported by: mrmachine 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 mrmachine 6 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 mrmachine 6 years ago.
Also fix ModelAdmin and InlineModelAdmin to allow a tuple for exclude.

Download all attachments as: .zip

Change History (4)

Changed 6 years ago by mrmachine

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

comment:1 Changed 6 years ago by brosner

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Changed 6 years ago by mrmachine

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

comment:2 Changed 6 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.