Opened 9 years ago

Closed 9 years ago

#5199 closed (fixed)

FormSet uses incorrect logic for is_bound

Reported by: David Blewett <david@…> Owned by: Adrian Holovaty
Component: Forms Version: newforms-admin
Severity: Keywords: FormSet logic
Cc: david@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The init logic of the FormSet is incorrect, and doesn't follow the logic of a Form:

self.is_bound = data is not None and files is not None


self.is_bound = data is not None or files is not None

The "and" in the FormSet code makes a FormSet that is passed data but no files set is_bound = False.

Attachments (1)

formset_logic.patch (548 bytes) - added by David Blewett <david@…> 9 years ago.
Patch that switches logic from "and" to "or"

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by David Blewett <david@…>

Attachment: formset_logic.patch added

Patch that switches logic from "and" to "or"

comment:1 Changed 9 years ago by David Blewett <david@…>

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

The reason why I ran into this is that calling FormSet.is_valid() will raise an error about self._is_valid not existing (due to it not getting set until the end of self.full_clean() which gets short-circuited by a check for self.is_bound).

comment:2 Changed 9 years ago by Russell Keith-Magee

Resolution: fixed
Status: newclosed

(In [5931]) newforms-admin: Fixed #5199 -- Corrected is_bound logic for formsets. Well spotted, David Blewett <david@…>.

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