summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-05-10 15:56:20 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-07-08 09:58:50 +0200
commit85b1e1a86edfc90eb236efb588b57e29d1fbd97e (patch)
tree57448f647d5d9fbbccf3057387fb0c21370e54ee /ishtar_common
parent993da19467e202e35dc253ee7326d62b8734b7ca (diff)
downloadIshtar-85b1e1a86edfc90eb236efb588b57e29d1fbd97e.tar.bz2
Ishtar-85b1e1a86edfc90eb236efb588b57e29d1fbd97e.zip
Admin - Export - CSV: field sort function -> lambda (refs #5251)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/admin.py9
1 files changed, 2 insertions, 7 deletions
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")