Disable link to edit object in django's admin (display list only)?

后端 未结 12 553
渐次进展
渐次进展 2020-12-12 22:05

In Django\'s admin, I want disable the links provided on the \"select item to change\" page so that users cannot go anywhere to edit the item. (I am going to limit

12条回答
  •  隐瞒了意图╮
    2020-12-12 22:51

    In more "recent" versions of Django, since at least 1.9, it is possible to simple determine the add, change and delete permissions on the admin class. See the django admin documentation for reference. Here is an example:

    @admin.register(Object)
    class Admin(admin.ModelAdmin):
    
        def has_add_permission(self, request):
            return False
    
        def has_change_permission(self, request, obj=None):
            return False
    
        def has_delete_permission(self, request, obj=None):
            return False
    

提交回复
热议问题