diff options
| author | Vasilis Aggelou <dimitrovasilis@hotmail.com> | 2017-09-04 12:24:34 +0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-01-05 18:28:45 -0500 |
| commit | 777f216d555496798a1e65fd899b0f8a0349aeca (patch) | |
| tree | c7019a417caf39f4d7a9acfd6b7629029befa3cc /docs/ref | |
| parent | ec2ce4517ac89f6c6334fe5322d1fc2007dfcbd4 (diff) | |
Fixed #15522 -- Added ModelAdmin.delete_queryset() to customize "delete selected objects" deletion.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/admin/actions.txt | 5 | ||||
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 9 |
2 files changed, 12 insertions, 2 deletions
diff --git a/docs/ref/contrib/admin/actions.txt b/docs/ref/contrib/admin/actions.txt index c6f210b1de..c23c647a72 100644 --- a/docs/ref/contrib/admin/actions.txt +++ b/docs/ref/contrib/admin/actions.txt @@ -27,8 +27,9 @@ models. For example, here's the user module from Django's built-in has an important caveat: your model's ``delete()`` method will not be called. - If you wish to override this behavior, simply write a custom action which - accomplishes deletion in your preferred manner -- for example, by calling + If you wish to override this behavior, you can override + :meth:`.ModelAdmin.delete_queryset` or write a custom action which does + deletion in your preferred manner -- for example, by calling ``Model.delete()`` for each of the selected items. For more background on bulk deletion, see the documentation on :ref:`object diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 1f7b7f152e..7622477036 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1391,6 +1391,15 @@ templates used by the :class:`ModelAdmin` views: operations. Call ``super().delete_model()`` to delete the object using :meth:`.Model.delete`. +.. method:: ModelAdmin.delete_queryset(request, queryset) + + .. versionadded:: 2.1 + + The ``delete_queryset()`` method is given the ``HttpRequest`` and a + ``QuerySet`` of objects to be deleted. Override this method to customize + the deletion process for the "delete selected objects" :doc:`action + <actions>`. + .. method:: ModelAdmin.save_formset(request, form, formset, change) The ``save_formset`` method is given the ``HttpRequest``, the parent |
