How hide delete item in django admin TabularInline

Submitted 3 years, 7 months ago
Ticket #161
Views 1524
Language/Framework Django
Priority Medium
Status Closed

I have admin view with tabular inline:

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]

I want form with three other inline form. This inline form always will be tree. I hide add another button. I don't want delete inline item button in form. How can I delete or hide this button? This button can't be show to user.

Submitted on Sep 13, 20
add a comment

1 Answer

Verified

May b this will help !!

class EvalInstallationTenantInline(admin.StackedInline):
    model = EvalInstallationTenant
    extra = 0
    verbose_name_plural = 'Tenants'
    readonly_fields = ('attributeinfo', 'overrideinfo', 'editlink', )
    exclude = ['msp_host']

Submitted 3 years, 6 months ago


Latest Blogs