Opened 4 years ago

Closed 3 years ago

#18906 closed Bug (fixed)

BaseModelFormSet.validate_unique should ignore forms marked for deletion

Reported by: c.pollock@… Owned by: nobody
Component: Forms Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


is_valid() returns false for a formset where uniquness is violated even if one of the forms where the violation occurs has DELETE set to true in cleaned data

so maybe line 521 in django/forms/ which is currently

if not hasattr(form, "cleaned_data"):


should read something like, so it will ignore forms that are getting deleted anyway

if not hasattr(form, "cleaned_data") or form.cleaned_data.get('DELETE', True):


unless of course I have completely missed the point


Attachments (1)

18906-1.diff (5.4 KB) - added by claudep 4 years ago.
Do not validate deleted forms

Download all attachments as: .zip

Change History (4)

comment:1 Changed 4 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

I was able to reproduce the issue in a test.

Changed 4 years ago by claudep

Do not validate deleted forms

comment:2 Changed 4 years ago by claudep

  • Has patch set

comment:3 Changed 3 years ago by Claude Paroz <claude@…>

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

In f44922c79516b9caf0e09fb060f20c896668b90f:

Fixed #18906 -- Ignored to-be-deleted forms in formset validate_unique

Thanks c.pollock at for the report.

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