Answers for "django model order"

6

django desc order

Obj.objects.all().order_by('-id')
Posted by: Guest on August-08-2020
1

order by listview django

class Reviews(ListView):
    model = ProductReview
    paginate_by = 50
    template_name = 'review_system/reviews.html'
	#add ordering: the least before the attribute means decreasing order
    ordering = ['-date_created']
Posted by: Guest on December-21-2020
1

django order by

Entry.objects.filter(pub_date__year=2005).order_by('-pub_date', 'headline')
Posted by: Guest on June-12-2020
1

django order by

#Add this to your models.py class, and dont remove the comma!
class Meta:
        ordering = ('yourfeild',)
Posted by: Guest on January-31-2021

Python Answers by Framework

Browse Popular Code Answers by Language