{{{
from django.contrib import admin
class SaleInline(admin.TabularInline):
model = Sale
@admin.display(description="Price")
def cost(sale):
return sale.price - sale.discount
fields = ("product", "count", "cost")
}}}
== FieldError
**Unknown field(s) (cost) specified for Sale**
--
Ticket URL: <https://code.djangoproject.com/ticket/34292>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> {{{InlineModelAdmin}}} doesn't support display function
>
> {{{
> from django.contrib import admin
>
> class SaleInline(admin.TabularInline):
> model = Sale
>
> @admin.display(description="Price")
> def cost(sale):
> return sale.price - sale.discount
>
> fields = ("product", "count", "cost")
> }}}
>
> == FieldError
> **Unknown field(s) (cost) specified for Sale**
New description:
{{{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**
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34292#comment:1>
* version: 4.2 => 4.1
--
Ticket URL: <https://code.djangoproject.com/ticket/34292#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
`cost` should be added to the
[https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.readonly_fields
readonly_fields].
Please don't use Trac as a support channel. Closing per
TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/34292#comment:3>