adminにカスタム列を使用してレコードをソートする方法を理解できません - hours_to_deadline
(列ヘッダーをクリックしたとき)。私の場合、それはタイムディスタです。Django - カスタム列別にレコードをソート
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
または類似した何かをすることはできません。
あなたは何をすべきか知っていますか?
で私はだけtime_to_deadlineを使用して注文したいです、管理者が注文をクリックすると –