Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[1.7.x] Added a unit test to ensure models cannot be ordered by a M2M…

… field.

Backport of 865bc71 from master
  • Loading branch information...
commit 2100bcef41a9f24764289b44976a08b7e5c5666f 1 parent 9918b76
@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
@@ -375,6 +375,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.