Is there any simple way to reverse the order of a 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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With