summaryrefslogtreecommitdiff
path: root/django/contrib/admin/checks.py
diff options
context:
space:
mode:
authorRodrigo Vieira <rodrigo.vieira@gmail.com>2026-04-22 18:53:27 -0300
committerJacob Walls <jacobtylerwalls@gmail.com>2026-04-22 22:22:55 -0400
commitfa2a3de6ede10b005fc2c1d23f4cffb53eaec425 (patch)
tree2fbb49592272a9b5b54ae9457ba0e2072dabe74f /django/contrib/admin/checks.py
parenta586f03f36f511064f171c0e30f4ca2ebfd60085 (diff)
Fixed #10919 -- Added delete_confirmation_max_display to ModelAdmin.
The new ModelAdmin.delete_confirmation_max_display attribute allows limiting the number of related objects shown on the delete confirmation page. When the limit is reached, a "…and N more objects." message is shown. The feature relies on a new truncated_unordered_list template filter added to django.contrib.admin.templatetags.admin_filters. Thanks Jacob Tyler Walls for the review and guidance, Tobias McNulty for the report, and terminator14 for the solution suggested.
Diffstat (limited to 'django/contrib/admin/checks.py')
-rw-r--r--django/contrib/admin/checks.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index d14515e8a4..7baaa38a29 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -842,6 +842,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
*self._check_search_fields(admin_obj),
*self._check_date_hierarchy(admin_obj),
*self._check_actions(admin_obj),
+ *self._check_delete_confirmation_max_display(admin_obj),
]
def _check_save_as(self, obj):
@@ -1089,6 +1090,25 @@ class ModelAdminChecks(BaseModelAdminChecks):
else:
return []
+ def _check_delete_confirmation_max_display(self, obj):
+ """Check that delete_confirmation_max_display is
+ a non-negative integer or None."""
+
+ if obj.delete_confirmation_max_display is None:
+ return []
+ if (
+ not isinstance(obj.delete_confirmation_max_display, int)
+ or obj.delete_confirmation_max_display < 0
+ ):
+ return must_be(
+ "a non-negative integer or None",
+ option="delete_confirmation_max_display",
+ obj=obj,
+ id="admin.E131",
+ )
+ else:
+ return []
+
def _check_list_per_page(self, obj):
"""Check that list_per_page is an integer."""