开发者

django comment: how to specify the sort direction?

开发者 https://www.devze.com 2023-03-03 20:42 出处:网络
I am using comment app in django, but currently the sort directio开发者_JS百科n is by date(from old to new), I want the comments are displayed by date from new to old, how to change it?you can do:

I am using comment app in django, but currently the sort directio开发者_JS百科n is by date(from old to new), I want the comments are displayed by date from new to old, how to change it?


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 django documentation

0

精彩评论

暂无评论...
验证码 换一张
取 消