Django管理员操作delete_selected是下拉列表中的最后一个选项

时间:2018-01-11 15:09:02

标签: python django django-admin

我想在管理界面的下拉列表中显示delete_selected操作作为一个模型的最后一个选项。

1 个答案:

答案 0 :(得分:0)

我设法让它像这样工作。会有更好的方式吗?

class MyModelAdmin(admin.ModelAdmin):

actions = ['soft_delete_selected', 'soft_undelete_selected']

def get_actions(self, request):
    actions = super(MyModelAdmin, self).get_actions(request)

    action = actions['delete_selected']
    del actions['delete_selected']
    actions['delete_selected'] = action

    return actions