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

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

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -