Skip to content

Commit a8c63d9

Browse files
authored
order_by - don't add pk when the last is -pk either (iommirocks#707)
2 parents 90b3372 + 717f163 commit a8c63d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iommi/table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ def sorter(
24602460
sort_keys = [('-' + x if descending else x) for x in sort_keys]
24612461
if table.model is not None and table.model._meta.ordering:
24622462
sort_keys.extend(table.model._meta.ordering)
2463-
if sort_keys[-1] != 'pk':
2463+
if sort_keys[-1] not in ('pk', '-pk'):
24642464
sort_keys.append('pk') # Add pk to always guarantee stable order for pagination.
24652465
return rows.order_by(*sort_keys)
24662466

0 commit comments

Comments
 (0)