1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #22172 -- Allowed index_together to be a single list (rather than list of lists)..

Thanks EmilStenstrom for the suggestion.
This commit is contained in:
Anubhav Joshi
2014-03-02 00:36:15 +05:30
committed by Tim Graham
parent 3273bd7b25
commit bb2ca9fe6c
10 changed files with 67 additions and 19 deletions

View File

@@ -45,10 +45,7 @@ class IndexTogetherTests(IsolatedModelsTestCase):
def test_list_containing_non_iterable(self):
class Model(models.Model):
class Meta:
index_together = [
'non-iterable',
'second-non-iterable',
]
index_together = [('a', 'b'), 42]
errors = Model.check()
expected = [
@@ -139,6 +136,22 @@ class UniqueTogetherTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
def test_non_list(self):
class Model(models.Model):
class Meta:
unique_together = 'not-a-list'
errors = Model.check()
expected = [
Error(
'"unique_together" must be a list or tuple.',
hint=None,
obj=Model,
id='E008',
),
]
self.assertEqual(errors, expected)
def test_valid_model(self):
class Model(models.Model):
one = models.IntegerField()