diff options
| author | Rodrigo Vieira <rodrigo.vieira@gmail.com> | 2026-04-22 18:53:27 -0300 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-04-22 22:22:55 -0400 |
| commit | fa2a3de6ede10b005fc2c1d23f4cffb53eaec425 (patch) | |
| tree | 2fbb49592272a9b5b54ae9457ba0e2072dabe74f /tests/admin_views/test_actions.py | |
| parent | a586f03f36f511064f171c0e30f4ca2ebfd60085 (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/test_actions.py')
| -rw-r--r-- | tests/admin_views/test_actions.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/admin_views/test_actions.py b/tests/admin_views/test_actions.py index c2c18e0b74..de5f5462a3 100644 --- a/tests/admin_views/test_actions.py +++ b/tests/admin_views/test_actions.py @@ -220,6 +220,19 @@ class AdminActionsTest(TestCase): # BookAdmin.get_deleted_objects() returns custom text. self.assertContains(response, "a deletable object") + def test_delete_selected_uses_delete_confirmation_max_display(self): + book = Book.objects.create(name="Test Book") + data = { + ACTION_CHECKBOX_NAME: [book.pk], + "action": "delete_selected", + "index": 0, + } + response = self.client.post(reverse("admin2:admin_views_book_changelist"), data) + self.assertContains(response, "a deletable object") + self.assertContains(response, "…and 2 more objects.") + self.assertNotContains(response, "another object") + self.assertNotContains(response, "last object") + def test_custom_function_mail_action(self): """A custom action may be defined in a function.""" action_data = { |
