from django.contrib.admin.actions import delete_selected
from Test.app.models import Post
from django.contrib import admin
class PostModelAdmin(admin.ModelAdmin):
fields= ('gender',)
list_display = ('gender',)
def mark_deleted(self, request, queryset):
print "deleted"
return delete_selected(self, request, queryset)
actions = [mark_deleted,]
admin.site.register(Post, PostModelAdmin)
I just called the default bulk delete functions. It produces the following error.
Exception Type: AttributeError
Exception Value:
'PostModelAdmin' object has no attribute 'model'
What I need to pass for ‘modeladmin’ attribute?
def delete_selected(modeladmin, request, queryset):
New issue
All the error are gone now. But none of the objects got deleted. This action always says like ‘No Objects selected’. Any suggestions?
The action is expecting a ModelAdmin instance, not a class.
selfis the right thing to pass here.