我想在Django Admin内联模型中添加一行,在这里我可以总计计算出的税后金额。
我有两个模型:约会和Invoice_Line,在管理员中,我将Invoice_Line模型显示为约会的内联模型(如下所示的模型管理员注册):
admin.py:
class Inv_LineInline(admin.TabularInline):
model = Invoice_Line
extra = 1
fields = ['item_desc','item_quantity','tip_amount','item_price','total_before_tax','stax_rate','stax_amount','total_after_tax']
readonly_fields = ['item_price','total_before_tax','stax_rate','stax_amount','total_after_tax']
@admin.register (Appointment)
class Appointment(admin.ModelAdmin):
list_display = ('appointment_ref','create_date','appointment_date',
'appointment_time','assigned_associate',
'check_in', 'appointment_status', 'last_name', 'first_name')
list_editable = ('assigned_associate','check_in')
search_fields = ('appointment_ref','create_date','appointment_date', 'appointment_time','requested_associate__associate','assigned_associate__associate','check_in', 'last_name', 'first_name')
list_filter = ('check_in','appointment_status',)
inlines = [Inv_LineInline]
管理员更改模板的外观如下链接所示:
我想修改该内联以包括总计行,在其中我可以为所有行添加“税后总计”。我将如何去做?
我是Django的新手,非常感谢我能提供的任何帮助。