[Django]-Django: Sort order the list in objects

3👍

Also you can use in_bulk() and then just get dict values in defined order. Wrap this in custom manager for further comfort

1👍

You’ll need to use CASE ... WHEN ... THEN ... END in order to sort your IDs. Pass the full CASE clause in the select argument of extra(), and the use the order_by argument with the given field name.

Leave a comment