Code

Opened 6 years ago

Closed 6 years ago

Last modified 5 years ago

#9319 closed (fixed)

error when a field is used in twice in unique_together

Reported by: ctao 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 ctao 6 years ago.
9319.diff (662 bytes) - added by ctao 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by ctao

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Summary changed from forms/models.py bugs to error when a field is used in twice in unique_together
  • Triage Stage changed from Unreviewed to Accepted

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 6 years ago by mtredinnick

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 6 years ago by mtredinnick

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

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

comment:4 Changed 6 years ago by mtredinnick

(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 6 years ago by ctao

comment:5 Changed 5 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.