Fixed #27889 -- Fixed incorrect check error if ModelAdmin.ordering refers to 'pk'.
This commit is contained in:
parent
7588d7e439
commit
d82ee32aac
|
@ -465,7 +465,8 @@ class BaseModelAdminChecks:
|
||||||
else:
|
else:
|
||||||
if field_name.startswith('-'):
|
if field_name.startswith('-'):
|
||||||
field_name = field_name[1:]
|
field_name = field_name[1:]
|
||||||
|
if field_name == 'pk':
|
||||||
|
return []
|
||||||
try:
|
try:
|
||||||
model._meta.get_field(field_name)
|
model._meta.get_field(field_name)
|
||||||
except FieldDoesNotExist:
|
except FieldDoesNotExist:
|
||||||
|
|
|
@ -794,7 +794,7 @@ class OrderingCheckTests(CheckTestCase):
|
||||||
|
|
||||||
def test_valid_case(self):
|
def test_valid_case(self):
|
||||||
class TestModelAdmin(ModelAdmin):
|
class TestModelAdmin(ModelAdmin):
|
||||||
ordering = ('name',)
|
ordering = ('name', 'pk')
|
||||||
|
|
||||||
self.assertIsValid(TestModelAdmin, ValidationTestModel)
|
self.assertIsValid(TestModelAdmin, ValidationTestModel)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue