Opened 8 years ago

Closed 8 years ago

Last modified 8 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: UI/UX:

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 8 years ago.
9319.diff (662 bytes) - added by tangc 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by tangc

Attachment: models.py added

comment:1 Changed 8 years ago by Chris Beaven

Needs documentation: unset
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 Changed 8 years ago by Malcolm Tredinnick

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 Changed 8 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

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

comment:4 Changed 8 years ago by Malcolm Tredinnick

(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.

Changed 8 years ago by tangc

Attachment: 9319.diff added

comment:5 Changed 8 years ago by (none)

milestone: post-1.0

Milestone post-1.0 deleted

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