Django中的默认“delete selected”管理员操作

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (121)

如何删除或更改Django管理面板中默认管理操作的详细名称“delete selected X item”?

提问于
用户回答回答于

写入admin.py

from django.contrib.admin.actions import delete_selected
delete_selected.short_description = u'How\'s this for a name?'

用Django 1.1版本进行了测试:

>>> import django
>>> django.VERSION
(1, 1, 0, 'beta', 1)
用户回答回答于
class FlowAdmin(admin.ModelAdmin):
    actions = ['delete_model']

    def get_actions(self, request):
        actions = super(MyModelAdmin, self).get_actions(request)
        del actions['delete_selected']
        return actions

    def delete_model(self, request, obj):
        for o in obj.all():
            o.delete()
    delete_model.short_description = 'Delete flow'

admin.site.register(Flow, FlowAdmin)

扫码关注云+社区

领取腾讯云代金券