summaryrefslogtreecommitdiff
path: root/tests/admin_checks/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_checks/tests.py')
-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"]