Reverse Queryset Order in Django -


this question has answer here:

i guess question super simple , short but...

is there simple way reverse order of queryset in django?

example:

li = [1,2,3]

queryset = collection.objects.filter(pk__in = li)

you can use

queryset = reversed(collection.objects.filter(pk__in = li)) 

or

queryset = collection.objects.filter(pk__in = li).reverse() 

Comments

Popular posts from this blog

asp.net mvc - Cannot display error message on Editor or EditorFor -

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Using str_replace to translate a MySQL Table in html -