python - 如何为 Django 内联模型管理员添加总行?
问题描述
我想在 Django Admin 内联模型中添加一行,我可以在其中汇总计算的税后金额。
我有两个模型:Appointments 和 Invoice_Line,在管理员中我将 Invoice_Line 模型显示为 Appointments 的内联(模型管理员注册如下所示):
管理员.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 新手,非常感谢我能得到的任何帮助。
解决方案
推荐阅读
- r - R聚合动态添加的列,每个列都有一个单独的函数
- r - 如何防止 data.frame 函数对我的数据进行排序
- angular - Ionic Angular Live-Reload 重新加载时找不到文件
- c# - 在 C# Autofac 中,如何从具有多个具体类的单个接口解析类
- graphql - 中继编译器语法错误:预期名称,找到“}”
- r - 聚集标准误和缺失值
- java - onErrorResume 和 onErrorReturn 的区别
- java - 如何在 Payara Docker 容器上安装 PostgreSQL?
- json - 如何从 json 中提取这些值
- html - 我已尽我所能,但我的网站无法在 iPhone 上运行或响应