Here is the code :
// admin.py
@admin.register(BusinessParent)
class BusinessParentAdmin(admin.ModelAdmin):
list_filter = [
"status",
]
list_display = [
"id",
"short_code",
"slug",
"title",
"desc",
"move_to_draft",
]
def move_to_draft(modeladmin, request, queryset):
"""
Admin action to move back to draft state
"""
if queryset.count() == 0:
return messages.error(request, "Select atleast one entry")
queryset.update(status=constants.BS_BUSINESS_PARENT_IS_NOT_VISIBLE)
for qs in queryset:
qs.save()
return messages.success(
request,
"Successfully moved {} rows to Draft state".format(len(queryset)),
)
move_to_draft.short_description = "Move Back to Draft"
actions = [
move_to_draft,
]
And when I head over to open it up in the admin panel I'm getting this error :
move_to_draft() missing 1 required positional argument: 'queryset'
Can anybody tell me what am I doing wrong here, and how I can correct it?
Aucun commentaire:
Enregistrer un commentaire