django comment: how to specify the sort direction?

630 views Asked by At

I am using comment app in django, but currently the sort direction is by date(from old to new), I want the comments are displayed by date from new to old, how to change it?

2

There are 2 answers

0
dting On BEST ANSWER

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

0
anonymous On

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