Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #21870 -- Admin check for list_editable_item

During the admin check for list_editable _check_list_editable_item
should return an empty list if all checks pass. Additionally the
Testcase test_readonly_and_editable was changed to test what the
name implies instead of duplicating the logic of test_readonly.
  • Loading branch information...
commit 38be3cf5e4c4980b484e1013c2a4047725ba8d3e 1 parent e1d18b9
@arneb arneb authored bmispelon committed
Showing with 26 additions and 0 deletions.
  1. +2 −0  django/contrib/admin/checks.py
  2. +24 −0 tests/admin_checks/tests.py
View
2  django/contrib/admin/checks.py
@@ -791,6 +791,8 @@ def _check_list_editable_item(self, cls, model, field_name, label):
id='admin.E126',
)
]
+ else:
+ return []
def _check_search_fields(self, cls, model):
""" Check search_fields is a sequence. """
View
24 tests/admin_checks/tests.py
@@ -52,6 +52,30 @@ def check(self, model, **kwargs):
def test_readonly_and_editable(self):
class SongAdmin(admin.ModelAdmin):
readonly_fields = ["original_release"]
+ list_display = ["pk", "original_release"]
+ list_editable = ["original_release"]
+ fieldsets = [
+ (None, {
+ "fields": ["title", "original_release"],
+ }),
+ ]
+
+ errors = SongAdmin.check(model=Song)
+ expected = [
+ checks.Error(
+ ('"list_editable[0]" refers to field "original_release", '
+ 'whih is not editable through the admin.'),
+ hint=None,
+ obj=SongAdmin,
+ id='admin.E126',
+ )
+ ]
+ self.assertEqual(errors, expected)
+
+ def test_editable(self):
+ class SongAdmin(admin.ModelAdmin):
+ list_display = ["pk", "title"]
+ list_editable = ["title"]
fieldsets = [
(None, {
"fields": ["title", "original_release"],
Please sign in to comment.
Something went wrong with that request. Please try again.