Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 865bc7178364145f901c5ac5a5b8eb722cc0a646 1 parent 9f18b6b
@PirosB3 PirosB3 authored timgraham committed
Showing with 21 additions and 0 deletions.
  1. +21 −0 tests/invalid_models_tests/test_models.py
View
21 tests/invalid_models_tests/test_models.py
@@ -540,6 +540,27 @@ class Meta:
]
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:
Please sign in to comment.
Something went wrong with that request. Please try again.