Opened 10 years ago

Closed 10 years ago

#22855 closed Bug (wontfix)

BaseFormSet.is_multipart() should not only consider the first Form

Reported by: mail@… Owned by: nobody
Component: Forms Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I am constructing a FormSet consisting of forms which have fields dynamically added in the init method of the form (to add a FileField only if no initial parameters are given).

However, it shows that BaseFormatSet.is_multipart() only considers the first form of the form set which causes my FormSet to fail if a FileField exists in some forms of the form set, but no in the first one.

Of course, I can solve my problem by implementing is_multipart() by myself but this seems like an ugly workaround. In my opinion, BaseFormatSet.is_multipart() should check all forms of the form set whether any of them contains a field which requires multipart encoding.

Change History (2)

comment:1 by anonymous, 10 years ago

Summary: BaseFormatSet.is_multipart() should not only consider the first FormBaseFormSet.is_multipart() should not only consider the first Form

comment:2 by Tim Graham, 10 years ago

Resolution: wontfix
Status: newclosed

I tend to think it's better for you to override it for your use case rather than impose the performance penalty of iterating through all forms on all users. There are similar assumptions in BaseFormSet, like the media property, that assume all forms will be identical.

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