我在django中使用注释应用程序,但是当前排序方向是按日期(从旧到新),我希望注释按日期从新到旧显示,如何更改?
you can do:
{% 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
You can use the minus sign to inverse the ordering.
t = Theme.objects.order_by('-pub_date')
Avoid using business logic in the templates as much as possible.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.