In Django Admin how do I disable the Delete link

前端 未结 7 2239
天命终不由人
天命终不由人 2020-12-07 22:29

I\'ve managed to disable the \"Delete selected\" action. Easy.

But a user can still click on an item and then there\'s the red Delete link at the bottom.

7条回答
  •  北海茫月
    2020-12-07 23:03

    Simple :)

    class DeleteNotAllowedModelAdmin(admin.ModelAdmin):
        # Other stuff here
        def has_delete_permission(self, request, obj=None):
            return False
    

提交回复
热议问题