Reputation: 2034
I have list1
in order by id. Like this:
['4','2','1','17'] #edited
How to get list2
from object Entry in order of list1
.
In the case Query ValueList, as well as on the question.
[u'4', u'2', u'1', u'17']
Because some properties are not in QuerySet
Thanks for your answers !
Upvotes: 3
Views: 585
Reputation: 32394
Also you can use in_bulk()
and then just get dict values in defined order. Wrap this in custom manager for further comfort
Upvotes: 3
Reputation: 798526
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.
Upvotes: 1