Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#9319 closed (fixed)

error when a field is used in twice in unique_together

Reported by: tangc Owned by: nobody
Component: Forms Version: 1.0
Severity: Keywords: forms/models.py
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The forms/models.py has the following code

at line 287 -- 289 for "Django version 1.0-post-release-SVN-SVN-unknown"

# Remove the data from the cleaned_data dict since it was invalid
for field_name in unique_check:

del self.cleaned_data[field_name]

The above code should be commented out for it leads to error or exception for the case of model

meta:

unique_together = (("QUESTION_FK", "PROTOCOL_FK"),("EMAIL", "PROTOCOL_FK"), )

This case need to check unique "PROTOCOL_FK" twice

Attachments (2)

models.py (28.7 KB ) - added by tangc 16 years ago.
9319.diff (662 bytes ) - added by tangc 16 years ago.

Download all attachments as: .zip

Change History (7)

by tangc, 16 years ago

Attachment: models.py added

comment:1 by Chris Beaven, 16 years ago

Needs tests: set
Patch needs improvement: set
Summary: forms/models.py bugserror when a field is used in twice in unique_together
Triage Stage: UnreviewedAccepted

It does seem that deleting from cleaned_data is quite redundant since full_clean removes the whole dict anyway.

ctao: thanks for the report however a try to use a descriptive summary and use a diff rather than attaching the full edited file (use svn diff > 9319.diff)

comment:2 by Malcolm Tredinnick, 16 years ago

Since we might (hopefully) be not completely removing cleaned_data when there's a validation failure in the future, it's worthwhile being neat and tidy here and removing the data that is problematic.

comment:3 by Malcolm Tredinnick, 16 years ago

Resolution: fixed
Status: newclosed

(In [9208]) Fixed #9319 -- Fixed a crash when using the same model field in multiple
unique_together constraints.

comment:4 by Malcolm Tredinnick, 16 years ago

(In [9209]) [1.0.X] Fixed #9319 -- Fixed a crash when using the same model field in multiple
unique_together constraints.

Backport of r9208 from trunk.

by tangc, 16 years ago

Attachment: 9319.diff added

comment:5 by (none), 15 years ago

milestone: post-1.0

Milestone post-1.0 deleted

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