Python Forum

Full Version: Order by Django
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all
I am not getting descending order of my DB table contents I am getting Ascending Order like this vege = Receipe.objects.all().order_by('-receipe_view_count')
>>> vege
<QuerySet [<Receipe: Receipe object (3)>, <Receipe: Receipe object (4)>, <Receipe: Receipe object (6)>, <Receipe: Receipe object (20)>, <Receipe: Receipe object (29)>, <Receipe: Receipe object (30)>, <Receipe: Receipe object (31)>, <Receipe: Receipe object (32)>, <Receipe: Receipe object (33)>, <Receipe: Receipe object (36)>, <Receipe: Receipe object (37)>, <Receipe: Receipe object (38)>]>.
It seems like you're encountering an issue with sorting your Django model objects in descending order based on the receipe_view_count field. Your query Receipe.objects.all().order_by('-receipe_view_count') should indeed return the records in descending order based on the receipe_view_count field.