Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Order by Django
#1
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)>]>.
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,350 Jun-30-2019, 12:21 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020