Skip to main content
 首页 » 编程设计

python之django 评论 : how to specify the sort direction

2025年05月04日23jiqing9006

我在django中使用评论应用程序,但目前排序方向是按日期(从旧到新),我希望评论按日期从新到旧显示,如何更改?

请您参考如下方法:

你可以这样做:

{% get_comment_list for event as comment_list %} 
{% for comment in comment_list reversed %} 
    ... 
{% endfor %} 

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for