0
0
mirror of https://github.com/django/django.git synced 2024-11-28 21:43:13 +01:00

Added a unit test to ensure models cannot be ordered by a M2M field.

This commit is contained in:
Daniel Pyrathon 2014-07-08 11:24:08 +02:00 committed by Tim Graham
parent 9f18b6bcb0
commit 865bc71783

View File

@ -540,6 +540,27 @@ class OtherModelTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
def test_non_valid(self):
class RelationModel(models.Model):
pass
class Model(models.Model):
relation = models.ManyToManyField(RelationModel)
class Meta:
ordering = ['relation']
errors = Model.check()
expected = [
Error(
"'ordering' refers to the non-existent field 'relation'.",
hint=None,
obj=Model,
id='models.E015',
),
]
self.assertEqual(errors, expected)
def test_ordering_pointing_to_missing_field(self):
class Model(models.Model):
class Meta: