summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorsiddhartha-star-dev <bestsid1@gmail.com>2022-02-18 23:04:05 +0530
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-04-25 11:00:50 +0200
commitdcebc5da4831d2982b26d00a9480ad538b5c5acf (patch)
tree77d40270ad5658e6101683d5fcf0ad991af66677 /tests
parented0a2c3238aa0b9c0d01c436d5bcd70930d696b0 (diff)
Refs #2259 -- Disallowed primary keys in ModelAdmin.list_editable.
Refs #32728.
Diffstat (limited to 'tests')
-rw-r--r--tests/admin_checks/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index aa87649dce..4d171ed737 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -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"]