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 4 years, 5 months ago
  2. Searching and Deleting Cache Entries in Admin tool by shootclub 2 years, 9 months ago
  3. syncdata command by graham 5 years, 8 months ago
  4. Specify a manager for the Admin by kylefox 6 years, 2 months ago
  5. Binding signals to abstract models by andreterra 1 year, 11 months ago

Comments

(Forgotten your password?)