Fixed #12647. Allow unique_together checks be specified as lists as well as tuples. Thanks, Honza Král.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12403 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
8f4540b2e6
commit
225c413b08
|
@ -683,7 +683,7 @@ class Model(object):
|
||||||
if name in exclude:
|
if name in exclude:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
unique_checks.append(check)
|
unique_checks.append(tuple(check))
|
||||||
|
|
||||||
# These are checks for the unique_for_<date/year/month>.
|
# These are checks for the unique_for_<date/year/month>.
|
||||||
date_checks = []
|
date_checks = []
|
||||||
|
|
|
@ -36,7 +36,7 @@ class UniqueTogetherModel(models.Model):
|
||||||
efield = models.EmailField()
|
efield = models.EmailField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = (('ifield', 'cfield',), ('ifield', 'efield'))
|
unique_together = (('ifield', 'cfield',), ['ifield', 'efield'])
|
||||||
|
|
||||||
class UniqueForDateModel(models.Model):
|
class UniqueForDateModel(models.Model):
|
||||||
start_date = models.DateField()
|
start_date = models.DateField()
|
||||||
|
|
|
@ -13,7 +13,7 @@ class GetUniqueCheckTests(unittest.TestCase):
|
||||||
m._get_unique_checks()
|
m._get_unique_checks()
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_unique_together_gets_picked_up(self):
|
def test_unique_together_gets_picked_up_and_converted_to_tuple(self):
|
||||||
m = UniqueTogetherModel()
|
m = UniqueTogetherModel()
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
([('ifield', 'cfield',),('ifield', 'efield'), ('id',), ], []),
|
([('ifield', 'cfield',),('ifield', 'efield'), ('id',), ], []),
|
||||||
|
|
Loading…
Reference in New Issue