开发者

django comment: how to specify the sort direction?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜