diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index 286c1169a4..f000fc269b 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -468,7 +468,8 @@ class BaseModelAdminChecks(object): else: if field_name.startswith('-'): field_name = field_name[1:] - + if field_name == 'pk': + return [] try: model._meta.get_field(field_name) except FieldDoesNotExist: diff --git a/tests/modeladmin/test_checks.py b/tests/modeladmin/test_checks.py index 0c66544b6b..ad43f34837 100644 --- a/tests/modeladmin/test_checks.py +++ b/tests/modeladmin/test_checks.py @@ -796,7 +796,7 @@ class OrderingCheckTests(CheckTestCase): def test_valid_case(self): class TestModelAdmin(ModelAdmin): - ordering = ('name',) + ordering = ('name', 'pk') self.assertIsValid(TestModelAdmin, ValidationTestModel)