1
0
mirror of https://github.com/django/django.git synced 2025-10-28 16:16:12 +00:00

Refs #2259 -- Disallowed primary keys in ModelAdmin.list_editable.

Refs #32728.
This commit is contained in:
siddhartha-star-dev
2022-02-18 23:04:05 +05:30
committed by Mariusz Felisiak
parent ed0a2c3238
commit dcebc5da48
2 changed files with 18 additions and 1 deletions

View File

@@ -363,6 +363,23 @@ class SystemChecksTestCase(SimpleTestCase):
]
self.assertEqual(errors, expected)
def test_pk_not_editable(self):
# PKs cannot be edited in the list.
class SongAdmin(admin.ModelAdmin):
list_display = ["title", "id"]
list_editable = ["id"]
errors = SongAdmin(Song, AdminSite()).check()
expected = [
checks.Error(
"The value of 'list_editable[0]' refers to 'id', which is not editable "
"through the admin.",
obj=SongAdmin,
id="admin.E125",
)
]
self.assertEqual(errors, expected)
def test_editable(self):
class SongAdmin(admin.ModelAdmin):
list_display = ["pk", "title"]