Django

Code

Ticket #9319 (closed: fixed)

Opened 2 months ago

Last modified 2 months ago

error when a field is used in twice in unique_together

Reported by: ctao Assigned to: nobody
Milestone: post-1.0 Component: Forms
Version: 1.0 Keywords: forms/models.py
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 1 Patch needs improvement: 1

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

models.py (28.7 kB) - added by ctao on 10/07/08 12:59:41.
9319.diff (0.6 kB) - added by ctao on 11/03/08 09:50:59.

Change History

10/07/08 12:59:41 changed by ctao

  • attachment models.py added.

10/07/08 17:59:15 changed by SmileyChris

  • needs_better_patch set to 1.
  • stage changed from Unreviewed to Accepted.
  • summary changed from forms/models.py bugs to error when a field is used in twice in unique_together.
  • needs_tests set to 1.
  • needs_docs changed.

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)

10/08/08 05:08:26 changed 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.

10/08/08 05:09:45 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

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

10/08/08 05:11:03 changed 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.

11/03/08 09:50:59 changed by ctao

  • attachment 9319.diff added.

Add/Change #9319 (error when a field is used in twice in unique_together)




Change Properties
Action