Is it possible to override the method used to call Django’s admin delete confirmation page?

1,346 views
Skip to first unread message

huu...@gmail.com

unread,
Jun 18, 2009, 4:41:20 PM6/18/09
to Django users
On Django's admin pages, I'd like to perform an action when the
administrator clicks the Delete button for an object. In other words,
I'd like to execute some code prior to arriving on the "Are you sure?"
delete confirmation page.

I realize I could override the template page for this object, but I
was hoping for something easier (i.e., override a method on the model
or the form).

Any thoughts?

Daniel Roseman

unread,
Jun 18, 2009, 4:55:32 PM6/18/09
to Django users
The method you need to override is on the ModelAdmin class, and is
called delete_view. Look in django.contrib.admin.options for the
original.
--
DR.

huu...@gmail.com

unread,
Jun 18, 2009, 5:09:38 PM6/18/09
to Django users
I just tried that and I didn't have any luck. As a sanity check, does
this look right:

====
class PersonAdmin(admin.ModelAdmin):
form = PersonAdminForm

def delete_view(self, request, object_id):
print 'it worked'
====

When I click the Delete button, I would expect to see "it worked" in
my logs. Unfortunately, no such luck.
Reply all
Reply to author
Forward
0 new messages