mirror of
https://github.com/django/django.git
synced 2025-08-04 19:08:28 +00:00
Fixed #11108 -- added ModelAdmin.delete_model, a hook with which to perform custom pre-post delete behavior. Thanks to Florian Apolloner for the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14673 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
0cf1c96d06
commit
274aba3b9b
5 changed files with 49 additions and 4 deletions
|
@ -757,6 +757,12 @@ templates used by the :class:`ModelAdmin` views:
|
|||
``ModelAdmin`` methods
|
||||
----------------------
|
||||
|
||||
.. warning::
|
||||
|
||||
:meth:`ModelAdmin.save_model` and :meth:`ModelAdmin.delete_model` must
|
||||
save/delete the object, they are not for veto purposes, rather they allow
|
||||
you to perform extra operations.
|
||||
|
||||
.. method:: ModelAdmin.save_model(self, request, obj, form, change)
|
||||
|
||||
The ``save_model`` method is given the ``HttpRequest``, a model instance,
|
||||
|
@ -770,6 +776,13 @@ For example to attach ``request.user`` to the object prior to saving::
|
|||
obj.user = request.user
|
||||
obj.save()
|
||||
|
||||
.. method:: ModelAdmin.delete_model(self, request, obj)
|
||||
|
||||
.. versionadded:: 1.3
|
||||
|
||||
The ``delete_model`` method is given the ``HttpRequest`` and a model instance.
|
||||
Use this method to do pre- or post-delete operations.
|
||||
|
||||
.. method:: ModelAdmin.save_formset(self, request, form, formset, change)
|
||||
|
||||
The ``save_formset`` method is given the ``HttpRequest``, the parent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue