summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorVincent-Vega <mortas.11@gmail.com>2014-05-27 08:48:50 -0700
committerSimon Charette <charette.s@gmail.com>2014-06-01 15:36:25 -0400
commitd04e7302240f5be34cdd303002bc8e7dcd81f529 (patch)
tree16faf4f42cd3c9d686e52be29742dc76e3cc3ccb /tests
parent7a38f889222dfbdf0e0d8d22001c30264d420054 (diff)
Fixed #22711 -- Adjusted ordering checks to allow implicit relation fields.
refs #19195.
Diffstat (limited to 'tests')
-rw-r--r--tests/invalid_models_tests/test_models.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 1338fcabcd..9cbaa8449c 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -415,6 +415,40 @@ class OtherModelTests(IsolatedModelsTestCase):
]
self.assertEqual(errors, expected)
+ def test_ordering_pointing_to_missing_foreignkey_field(self):
+ # refs #22711
+
+ class Model(models.Model):
+ missing_fk_field = models.IntegerField()
+
+ class Meta:
+ ordering = ("missing_fk_field_id",)
+
+ errors = Model.check()
+ expected = [
+ Error(
+ "'ordering' refers to the non-existent field 'missing_fk_field_id'.",
+ hint=None,
+ obj=Model,
+ id='models.E015',
+ )
+ ]
+ self.assertEqual(errors, expected)
+
+ def test_ordering_pointing_to_existing_foreignkey_field(self):
+ # refs #22711
+
+ class Parent(models.Model):
+ pass
+
+ class Child(models.Model):
+ parent = models.ForeignKey(Parent)
+
+ class Meta:
+ ordering = ("parent_id",)
+
+ self.assertFalse(Child.check())
+
@override_settings(TEST_SWAPPED_MODEL_BAD_VALUE='not-a-model')
def test_swappable_missing_app_name(self):
class Model(models.Model):