django listview 排序字段 order by listview django

Published on Aug. 22, 2023, 12:11 p.m.

列表中设置排序字段

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']

相关链接
https://www.codegrepper.com/code-examples/python/frameworks/django/order+by+listview+django

Tags: