Multiple Delete in Admin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from django.contrib.admin.decorators import admin_action

# inside CommentManager in django.contrib.comments.models


    @admin_action( name='Delete selected posts' )
    def multi_delete( self, id_list ):
        res = ""
        for id in id_list:
            obj = self.get( pk=id )
            res += repr( obj )
            obj.delete()
            res += "<br/>\n"
        return "Deleted %s" % res

More like this

  1. MPTTModelAdmin by anentropic 2 years, 6 months ago
  2. Hackish Way to Execute on manage.py Action by joshua 5 years, 2 months ago
  3. syncdata command by graham 3 years, 9 months ago
  4. Export Related as JSON Admin Action by johnboxall 2 years, 10 months ago
  5. Dynamically create Django admin actions by pantsman 2 years, 5 months ago

Comments

(Forgotten your password?)