diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-09-26 10:33:54 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-09-27 13:57:22 +0200 |
| commit | c7944628a1979453468d67818c63957532d396d8 (patch) | |
| tree | 6cf7fc23d5e5d244662048b785e127ea716cbde3 /tests/invalid_models_tests/test_models.py | |
| parent | c2678e49759e5c4c329bff0eeca2886267005d21 (diff) | |
Refs #30798 -- Prevented chaining fields from the same related model multiple times in model Meta.ordering.
Diffstat (limited to 'tests/invalid_models_tests/test_models.py')
| -rw-r--r-- | tests/invalid_models_tests/test_models.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index 0f1d1e4dc3..02db3ea54a 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -814,6 +814,26 @@ class OtherModelTests(SimpleTestCase): ) ]) + def test_ordering_pointing_multiple_times_to_model_fields(self): + class Parent(models.Model): + field1 = models.CharField(max_length=100) + field2 = models.CharField(max_length=100) + + class Child(models.Model): + parent = models.ForeignKey(Parent, models.CASCADE) + + class Meta: + ordering = ('parent__field1__field2',) + + self.assertEqual(Child.check(), [ + Error( + "'ordering' refers to the nonexistent field, related field, " + "or lookup 'parent__field1__field2'.", + obj=Child, + id='models.E015', + ) + ]) + def test_ordering_allows_registered_lookups(self): class Model(models.Model): test = models.CharField(max_length=100) |
