Opened 12 years ago

Closed 12 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

Description

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/models.py which is currently

if not hasattr(form, "cleaned_data"):

continue

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):

continue

unless of course I have completely missed the point

Cheers
Charlie

Attachments (1)

18906-1.diff (5.4 KB ) - added by Claude Paroz 12 years ago.
Do not validate deleted forms

Download all attachments as: .zip

Change History (4)

comment:1 by Claude Paroz, 12 years ago

Triage Stage: UnreviewedAccepted

I was able to reproduce the issue in a test.

by Claude Paroz, 12 years ago

Attachment: 18906-1.diff added

Do not validate deleted forms

comment:2 by Claude Paroz, 12 years ago

Has patch: set

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

Resolution: fixed
Status: newclosed

In f44922c79516b9caf0e09fb060f20c896668b90f:

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

Thanks c.pollock at bangor.ac.uk for the report.

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