Opened 17 years ago

Closed 17 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: no UI/UX: no

Description

The init logic of the FormSet is incorrect, and doesn't follow the logic of a Form:
http://code.djangoproject.com/browser/django/branches/newforms-admin/django/newforms/formsets.py#24

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

vs.
http://code.djangoproject.com/browser/django/trunk/django/newforms/forms.py#L61

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@…> 17 years ago.
Patch that switches logic from "and" to "or"

Download all attachments as: .zip

Change History (3)

by David Blewett <david@…>, 17 years ago

Attachment: formset_logic.patch added

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

comment:1 by David Blewett <david@…>, 17 years ago

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 by Russell Keith-Magee, 17 years ago

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