Fixed #30798 -- Fixed Meta.ordering validation for pk of related fields.

Regression in 440505cb2c.
This commit is contained in:
Hasan Ramezani 2019-09-27 12:16:26 +02:00 committed by Mariusz Felisiak
parent c7944628a1
commit 95a11578ce
2 changed files with 17 additions and 1 deletions

View file

@ -844,6 +844,18 @@ class OtherModelTests(SimpleTestCase):
with register_lookup(models.CharField, Lower):
self.assertEqual(Model.check(), [])
def test_ordering_pointing_to_related_model_pk(self):
class Parent(models.Model):
pass
class Child(models.Model):
parent = models.ForeignKey(Parent, models.CASCADE)
class Meta:
ordering = ('parent__pk',)
self.assertEqual(Child.check(), [])
def test_ordering_pointing_to_foreignkey_field(self):
class Parent(models.Model):
pass