From 58cafad032df0831ed37c88d04f7fc4dc4a1d3b2 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Thu, 7 Oct 2021 13:36:26 +0200 Subject: [PATCH] Sort buttons by category name instead of id in button list Signed-off-by: Yohann D'ANELLO --- apps/note/tables.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/note/tables.py b/apps/note/tables.py index 188683dd..1efd5c38 100644 --- a/apps/note/tables.py +++ b/apps/note/tables.py @@ -215,6 +215,9 @@ class ButtonTable(tables.Table): def render_amount(self, value): return pretty_money(value) + def order_category(self, queryset, is_descending): + return queryset.order_by(f"{'-' if is_descending else ''}category__name"), True + def render_hideshow(self, record): val = '