禁用admin中models的编辑链接和添加删除按钮
方法如下:
class MyModelAdmin(models.ModelAdmin):
...
List_display_links = None #禁用编辑链接
def has_add_permission(self, request):
# 禁用添加按钮
return False
def has_delete_permission(self, request, obj=None):
# 禁用删除按钮
return False
def get_actions(self, request):