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

后端 未结 12 541
渐次进展
渐次进展 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:37

    I overrided get_list_display_links method and action to None.

    class ChangeLogAdmin(admin.ModelAdmin):
        actions = None
        list_display = ('asset', 'field', 'before_value', 'after_value', 'operator', 'made_at')
    
        fieldsets = [
            (None, {'fields': ()}),
        ]
    
        def __init__(self, model, admin_site):
            super().__init__(model, admin_site)
    
        def get_list_display_links(self, request, list_display):
            super().get_list_display_links(request, list_display)
            return None
    

提交回复
热议问题