python · 8月 17, 2022 0

django listview 排序字段 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']

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

%d 博主赞过: