【发布时间】:2017-01-26 11:59:43
【问题描述】:
我不知道如何让管理员能够使用自定义列对记录进行排序 - hours_to_deadline(当他们点击列标题时)。就我而言,它是 timedelta。
class JobAdmin(SuperModelAdmin):
...
list_display = ['id', 'identificator', 'created', 'invoice__estimated_delivery','hours_to_deadline','customer__username', 'language_from__name', 'language_to__name',
'delivery__status', 'confirmed', 'approved', 'invoice__final_price']
...
def hours_to_deadline(self,obj):
try:
return (obj.invoice.estimated_delivery - now())
except:
return None
我找到了这个解决方案:https://stackoverflow.com/a/15935591/3371056
但就我而言,我不能只做sum 或类似的事情。
你知道该怎么做吗?
【问题讨论】:
标签: django django-admin