Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #11949 -- Added a hook to allow ModelAdmin customization of the…

… delete selected template. Thanks to bendavis78 for the report and patch, and Ramiro Morales for his cleanup work.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@12916 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c421a4fd92990fa830f2f645df044b0f0f1fc32a 1 parent 4e4deca
Russell Keith-Magee authored April 05, 2010
2  django/contrib/admin/actions.py
@@ -68,7 +68,7 @@ def delete_selected(modeladmin, request, queryset):
68 68
     }
69 69
 
70 70
     # Display the confirmation page
71  
-    return render_to_response(modeladmin.delete_confirmation_template or [
  71
+    return render_to_response(modeladmin.delete_selected_confirmation_template or [
72 72
         "admin/%s/%s/delete_selected_confirmation.html" % (app_label, opts.object_name.lower()),
73 73
         "admin/%s/delete_selected_confirmation.html" % app_label,
74 74
         "admin/delete_selected_confirmation.html"
1  django/contrib/admin/options.py
@@ -206,6 +206,7 @@ class ModelAdmin(BaseModelAdmin):
206 206
     change_form_template = None
207 207
     change_list_template = None
208 208
     delete_confirmation_template = None
  209
+    delete_selected_confirmation_template = None
209 210
     object_history_template = None
210 211
 
211 212
     # Actions
9  docs/ref/contrib/admin/index.txt
@@ -737,6 +737,15 @@ templates used by the :class:`ModelAdmin` views:
737 737
     Path to a custom template, used by :meth:`delete_view` for displaying a
738 738
     confirmation page when deleting one or more objects.
739 739
 
  740
+.. attribute:: ModelAdmin.delete_selected_confirmation_template
  741
+
  742
+    .. versionadded:: 1.2
  743
+
  744
+    Path to a custom template, used by the :meth:`delete_selected`
  745
+    action method for displaying a confirmation page when deleting one
  746
+    or more objects. See the :ref:`actions
  747
+    documentation<ref-contrib-admin-actions>`.
  748
+
740 749
 .. attribute:: ModelAdmin.object_history_template
741 750
 
742 751
     Path to a custom template, used by :meth:`history_view`.
1  tests/regressiontests/admin_views/models.py
@@ -119,6 +119,7 @@ class CustomArticleAdmin(admin.ModelAdmin):
119 119
     add_form_template = 'custom_admin/add_form.html'
120 120
     object_history_template = 'custom_admin/object_history.html'
121 121
     delete_confirmation_template = 'custom_admin/delete_confirmation.html'
  122
+    delete_selected_confirmation_template = 'custom_admin/delete_selected_confirmation.html'
122 123
 
123 124
     def changelist_view(self, request):
124 125
         "Test that extra_context works"
6  tests/regressiontests/admin_views/tests.py
@@ -606,6 +606,12 @@ def testCustomModelAdminTemplates(self):
606 606
         self.assertTemplateUsed(request, 'custom_admin/change_form.html')
607 607
         request = self.client.get('/test_admin/admin/admin_views/customarticle/1/delete/')
608 608
         self.assertTemplateUsed(request, 'custom_admin/delete_confirmation.html')
  609
+        request = self.client.post('/test_admin/admin/admin_views/customarticle/', data={
  610
+                'index': 0,
  611
+                'action': ['delete_selected'],
  612
+                '_selected_action': ['1'],
  613
+            })
  614
+        self.assertTemplateUsed(request, 'custom_admin/delete_selected_confirmation.html')
609 615
         request = self.client.get('/test_admin/admin/admin_views/customarticle/1/history/')
610 616
         self.assertTemplateUsed(request, 'custom_admin/object_history.html')
611 617
 
1  tests/templates/custom_admin/delete_selected_confirmation.html
... ...
@@ -0,0 +1 @@
  1
+{% extends "admin/delete_selected_confirmation.html" %}

0 notes on commit c421a4f

Please sign in to comment.
Something went wrong with that request. Please try again.