如何在django admin TabularInline中隐藏删除项目

时间:2016-11-30 08:09:14

标签: python django django-admin

我的管理视图有表格内联:

class AddressInline(admin.TabularInline):
    model = Address
    can_delete = False
    readonly_fields = ['kind']
    max_num = 3
    min_num = 3
    fields = (
       "kind", "country", "city", "post_code", "street", "no_house"
    )

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


class CustomerAdmin(admin.ModelAdmin):
    fields = (
        "first_name", "last_name", "pesel", "id_number", "birth_date",
        "photo"
    )
    inlines = [AddressInline]

我想要另外三种内联形式的表单。这种内联形式总是树。我隐藏添加另一个按钮。我不想在表单中删除内联项按钮。如何删除或隐藏此按钮?此按钮无法显示给用户。

0 个答案:

没有答案