Feature Request: delete_selected explicit option in admin

10 views
Skip to first unread message

sbrandt

unread,
Jan 30, 2012, 4:19:06 PM1/30/12
to django-d...@googlegroups.com
Hi,

according to this topic the only way to let the admin call delete() on every model using the delete_selected admin action is to copy the function, delete the queryset.delete()-method, add a obj.delete() in the loop, change the template path, copy the template and change the action name in it.
In addition, actions=[my_own_delete_selected] in the ModelAdmin class doesn't do the job, you must overwrite the get_actions method. That's much effort for such a simple task, especially because overwriting the delete() method is common as far as I know.

We could introduce a new admin option, let's say "ModelAdmin.delete_explicit" to do the job:

in django/contrib/actions/admin.py:45 (Django 1.3)
            for obj in queryset:
                obj_display = force_unicode(obj)
                modeladmin.log_deletion(request, obj, obj_display)
            queryset.delete()

            for obj in queryset:
                obj_display = force_unicode(obj)
                modeladmin.log_deletion(request, obj, obj_display)
                if modeladmin.delete_explicit:
                    obj.delete()
            if not modeladmin.delete_explicit:
                queryset.delete()     

Letting delete_explicit default to false, the change would be backwards compatible. 
Just a draft... What do you uthink?

Reply all
Reply to author
Forward
0 new messages