summaryrefslogtreecommitdiff
path: root/tests/admin_views/customadmin.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 /tests/admin_views/customadmin.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 'tests/admin_views/customadmin.py')
-rw-r--r--tests/admin_views/customadmin.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py
index a63d24a9ee..9621cb4d52 100644
--- a/tests/admin_views/customadmin.py
+++ b/tests/admin_views/customadmin.py
@@ -60,8 +60,19 @@ class CustomPwdTemplateUserAdmin(UserAdmin):
class BookAdmin(admin.ModelAdmin):
+ delete_confirmation_max_display = 1
+
def get_deleted_objects(self, objs, request):
- return ["a deletable object"], {"books": 1}, set(), []
+ return (
+ ["a deletable object", "another object", "last object"],
+ {"books": 1},
+ set(),
+ [],
+ )
+
+
+class BookAdminZeroDisplay(BookAdmin):
+ delete_confirmation_max_display = 0
site = Admin2(name="admin2")
@@ -80,3 +91,6 @@ site.register(models.Simple, base_admin.AttributeErrorRaisingAdmin)
simple_site = Admin2(name="admin4")
simple_site.register(User, CustomPwdTemplateUserAdmin)
+
+zero_display_site = Admin2(name="admin_zero_display")
+zero_display_site.register(models.Book, BookAdminZeroDisplay)