views:

77

answers:

2

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 !

+1  A: 

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.

Ignacio Vazquez-Abrams
+2  A: 

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

Dmitry Shevchenko