diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-11-21 19:00:40 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-11-21 19:00:40 +0000 |
| commit | 274aba3b9b8c48012a2d842790cb3df04dc9ae80 (patch) | |
| tree | c7986494f0b0e22060f6c53644fb9e352a72aafe /docs | |
| parent | 0cf1c96d062f64275c5babc7687b301f0bfa3bc6 (diff) | |
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
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 13 | ||||
| -rw-r--r-- | docs/topics/db/multi-db.txt | 6 |
2 files changed, 18 insertions, 1 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index ac517e868b..cc918be922 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -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 diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt index 1a939b0e3a..0e9290c37f 100644 --- a/docs/topics/db/multi-db.txt +++ b/docs/topics/db/multi-db.txt @@ -458,7 +458,7 @@ database other than that that specified by your router chain, you'll need to write custom :class:`~django.contrib.admin.ModelAdmin` classes that will direct the admin to use a specific database for content. -``ModelAdmin`` objects have four methods that require customization for +``ModelAdmin`` objects have five methods that require customization for multiple-database support:: class MultiDBModelAdmin(admin.ModelAdmin): @@ -469,6 +469,10 @@ multiple-database support:: # Tell Django to save objects to the 'other' database. obj.save(using=self.using) + def delete_model(self, requqest, obj): + # Tell Django to delete objects from the 'other' database + obj.delete(using=self.using) + def queryset(self, request): # Tell Django to look for objects on the 'other' database. return super(MultiDBModelAdmin, self).queryset(request).using(self.using) |
