Opened 2 years ago

Closed 23 months ago

#34292 closed New feature (invalid)

Support display function in InlineModelAdmin

Reported by: Al Mahdi Owned by: nobody
Component: contrib.admin Version: 4.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Al Mahdi)

InlineModelAdmin doesn't support display function

from django.contrib import admin

class SaleInline(admin.TabularInline):
    model = Sale

    @admin.display(description="Price")
    def cost(self, sale):
        return sale.price - sale.discount

    fields = ("product", "count", "cost")

FieldError

Unknown field(s) (cost) specified for Sale

Change History (3)

comment:1 by Al Mahdi, 2 years ago

Description: modified (diff)

comment:2 by Al Mahdi, 2 years ago

Version: 4.24.1

comment:3 by Mariusz Felisiak, 23 months ago

Resolution: invalid
Status: newclosed

cost should be added to the readonly_fields.

Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

Note: See TracTickets for help on using tickets.
Back to Top