[1.11.x] Fixed #27889 -- Fixed incorrect check error if ModelAdmin.ordering refers to 'pk'.
Backport of d82ee32aac
from master
This commit is contained in:
parent
f834c278b5
commit
93c8e2d50d
|
@ -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:
|
||||
|
|
|
@ -796,7 +796,7 @@ class OrderingCheckTests(CheckTestCase):
|
|||
|
||||
def test_valid_case(self):
|
||||
class TestModelAdmin(ModelAdmin):
|
||||
ordering = ('name',)
|
||||
ordering = ('name', 'pk')
|
||||
|
||||
self.assertIsValid(TestModelAdmin, ValidationTestModel)
|
||||
|
||||
|
|
Loading…
Reference in New Issue