Django: sort list in objects

I'm list1fine on id. Like this:

['4','2','1','17'] #edited

How to get list2from an Entry object in order list1.

In the case of Query ValueList, as well as the question.

[u'4', u'2', u'1', u'17']

Since some properties are not in QuerySet

Thank you for your responses!

+3
source share
2 answers

You can also use in_bulk()and then just get the dict values ​​in a specific order. Wrap this in a user manager for further comfort.

+3
source

CASE ... WHEN ... THEN ... END. CASE select extra() order_by .

+1

Source: https://habr.com/ru/post/1735083/


All Articles