Opened 8 years ago

Closed 8 years ago

#5199 closed (fixed)

FormSet uses incorrect logic for is_bound

Reported by: David Blewett <david@…> Owned by: adrian
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:

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

Download all attachments as: .zip

Change History (3)

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

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

comment:1 Changed 8 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 8 years ago by russellm

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

(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