#18574 closed Bug (fixed)
`BaseFormSet.is_valid` should call it's underlying forms' `is_valid`
Reported by: | Simon Charette | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | 1.4 |
Severity: | Normal | Keywords: | form formset is_valid |
Cc: | foonicorn | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The actual implementation of BaseFormSet.is_valid
checks if any of it's underlying forms have errors which short circuits any extra check-ups that could be defined in the form is_valid
method.
i,e.
class MyForm(Form): def is_valid(self): is_valid = super(MyForm, self).is_valid() print 'I was called' return is_valid and self.other_non_field_related_validation() MyFormSet = formset_factory(MyForm) # In this case calling MyFormSet(data).is_valid() will never print 'I was called'.
I'm submitting this as a bug since I don't think that's the expected behaviour.
Attachments (1)
Change History (9)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Has patch: | set |
---|
comment:3 by , 12 years ago
Needs tests: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:4 by , 12 years ago
Here's the workaround I use while this is not fixed:
from django.forms.formsets import BaseFormSet class BaseValidateFormSet(BaseFormSet): def is_valid(self): is_valid = super(BaseValidateFormSet, self).is_valid() for form in self: is_valid &= form.is_valid() or (self.can_delete and self._should_delete_form(form)) return is_valid
comment:5 by , 12 years ago
Cc: | added |
---|---|
Needs tests: | unset |
comment:6 by , 12 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Created a pull request which passes all tests on sqlite.