更新时间:2023-12-01 12:45:52
您的屏幕快照显示django-tables2正确地假设您的表上有页脚(是的!),但是lambda似乎没有返回任何内容.您可以尝试将其替换为类似的内容,以查看发生了什么事情:
Your screenshot shows that django-tables2 correctly assumes there is a footer on your table (yay!) but it seems that nothing is returned from the lambda. You can try to replace it by something like this to see what's going on:
def suma_footer(table):
try:
s = sum(x['suma'] for x in table.data)
print 'total:', s
except Exception e:
print str(e)
raise
return s
class MokejimaiTable(tables.Table):
suma = tables.Column(footer=suma_footer)
class Meta:
model = Mokejimai
attrs = {"class": "paleblue"}
fields = ('id', 'imone', 'sask', 'nr', 'suma', 'skola_pagal_agnum', 'data', 'date_entered')
如果在计算总和时出了问题,应该看到打印了一个异常,如果计算了一个值,那么应该看到打印了"total:".
If something goes wrong while computing the sum, you should see a exception printed, if a value is computed, you should see 'total: ' printed.