Opened 7 years ago
Closed 7 years ago
#28321 closed Cleanup/optimization (fixed)
FormSet.full_clean() shouldn't validate deleted forms
Reported by: | Peter Inglesby | Owned by: | Windson yang |
---|---|---|---|
Component: | Forms | Version: | 1.11 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Django validates all forms in a formset, including those which have been deleted by the user. This means that a formset's .errors
attribute can contain reports of errors that don't actually matter.
I'd argue that this violates the principle of least surprise, and that for a deleted form with errors, an empty dict should be added to ._errors
in a formset's full_clean()
.
At the very least this is a documentation bug, since https://docs.djangoproject.com/en/1.11/topics/forms/formsets/#custom-formset-validation suggests not continuing with a call to clean()
if a formset has any errors.
Change History (4)
comment:1 by , 7 years ago
Summary: | Errors on deleted forms shouldn't be included in a formset's errors → FormSet.full_clean() shouldn't validate deleted forms |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:2 by , 7 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Indeed, it looks inconsistent that
BaseFormSet.is_valid()
calls_should_delete_form()
butfull_clean()
doesn't.