Code

Ticket #3851: unique_together_patch.diff

File unique_together_patch.diff, 582 bytes (added by rezzrovv <pspierce@…>, 7 years ago)

fix unique_together and blank=True ForiegnKey reference

Line 
1Index: django/db/models/manipulators.py
2===================================================================
3--- django/db/models/manipulators.py    (revision 4775)
4+++ django/db/models/manipulators.py    (working copy)
5@@ -293,6 +293,9 @@
6             # This will be caught by another validator, assuming the field
7             # doesn't have blank=True.
8             return
9+        if field_val is '':
10+            kwargs['%s__isnull' % f.name] = True
11+            continue
12         if isinstance(f.rel, ManyToOneRel):
13             kwargs['%s__pk' % f.name] = field_val
14         else: