summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-22 19:19:36 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2022-12-22 19:19:36 +0100
commitcf6d6f87230aaeb8a6375c9d92f7f90d24dd8082 (patch)
tree7084bb9c8a835bd35c7e33b0cec4c692830267fa
parent476a4e6d3e025d1b8260e358f00ba4ffec8d1c61 (diff)
downloadIshtar-cf6d6f87230aaeb8a6375c9d92f7f90d24dd8082.tar.bz2
Ishtar-cf6d6f87230aaeb8a6375c9d92f7f90d24dd8082.zip
Search: sort by ID by default
-rw-r--r--ishtar_common/views_item.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py
index 930cd13e5..58b8e273a 100644
--- a/ishtar_common/views_item.py
+++ b/ishtar_common/views_item.py
@@ -2155,16 +2155,17 @@ def get_item(
if k.endswith("[column]"):
sorts[num][1] = request_items[k]
sign = ""
- if not sorts and model._meta.ordering:
- orders = [k for k in model._meta.ordering]
- items = items.order_by(*orders)
+ if not sorts:
+ items = items.order_by("id")
else:
orders = []
+ sort_keys = list(sorts.keys())
for idx in sorted(sorts.keys()):
signe, col_num = sorts[idx]
col_num = int(col_num)
- # remove id and link col
- if col_num < 2:
+ # id or link col
+ if col_num < 2 and len(sort_keys) <= 2:
+ orders.append("id")
continue
k = query_table_cols[col_num - 2]
if k in request_keys: