diff options
| author | Vincent-Vega <mortas.11@gmail.com> | 2014-05-27 08:48:50 -0700 |
|---|---|---|
| committer | Simon Charette <charette.s@gmail.com> | 2014-06-01 15:37:57 -0400 |
| commit | d773a08b270e3b2c387985a9d9a4d01c991469c8 (patch) | |
| tree | 116387026c2101f7ad39d940f1b07feea123c897 /tests/invalid_models_tests/test_models.py | |
| parent | 33511662ddbff0ca22cf5a0b7fdeca2f6764759f (diff) | |
[1.7.x] Fixed #22711 -- Adjusted ordering checks to allow implicit relation fields.
refs #19195.
Backport of d04e730224 from master
Diffstat (limited to 'tests/invalid_models_tests/test_models.py')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 34 |
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 e090ade34b..cf5abb2f6c 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -391,6 +391,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): |
