Display Model in Admin Django.How

Author avatar wrote on 07/06/2022


    class TextContentAdmin(admin.ModelAdmin):
    list_display = ("name", "page", "en_text", "ar_text")
    list_filter = ("page",)


Remove Delete Selected

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

Disallow Delete

    def has_delete_permission(self, request, obj=None):
        return False

Make Name Read Only

    readonly_fields = ["name"]

CRUDgen Django CRUD generator