0
我论文模型和管理模型显示beloy增加额外排在Django联模板
我想在模型交易,显示总金额(那是量字段的总和)
有不是在Inline中更改列表的方法如何执行此操作
class TransactionAdmin(admin.ModelAdmin):
inlines = [TransactionAmountInline, AmountPaidInline, PhotosInline]
fields = ('customer', 'title', 'description', 'created_at')
readonly_fields = ('updated_at',)
list_display = ('title', 'customer')
class AmountPaidInline(admin.TabularInline):
model = AmountPaid
extra = 0
class AmountPaid(models.Model):
transaction = models.ForeignKey(Transactions)
description = models.TextField(null=True)
amount = models.DecimalField(max_digits=19, decimal_places=4)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
谢谢您的回答居然是我我要的是显示在变化形式sum_amount(当你点击交易链接)我知道我可以覆盖更改列表视图并将总额添加到额外的上下文中,但我想要显示总金额显示在其将要显示的AmountPaidInline表单中 – user2388404 2014-12-10 18:55:16
简而言之,我想在内联中添加另一行以显示AmountPaind模型中的总金额 – user2388404 2014-12-10 19:02:20
请给我更多h elp在这 – user2388404 2014-12-16 07:10:01