From 5f574fffb6474f98ca75671e22fc2e840b69a69c Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 10 May 2022 15:56:20 +0200 Subject: Admin - Export - CSV: field sort function -> lambda (refs #5251) --- ishtar_common/admin.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/admin.py b/ishtar_common/admin.py index f5729d9de..3ae767393 100644 --- a/ishtar_common/admin.py +++ b/ishtar_common/admin.py @@ -170,14 +170,9 @@ def export_as_csv_action( if hasattr(modeladmin, "CSV_FIELD_ORDER"): field_order = modeladmin.CSV_FIELD_ORDER - def sort_csv(value): - if value not in field_order: - return 1000 - else: - return field_order.index(value) - field_names = sorted( - field_names, key=sort_csv + field_names, + key=lambda x: field_order.index(x) if x in field_order else 1000 ) response = HttpResponse(content_type="text/csv") -- cgit v1.2.3