1

I want to sorting items from database in descending order in template page

{% for n in article.comment_set.all %}
  {{ n.text }}
{% endfor %}

Model Example:

class comment(models.Model):
   text = models.TextField(verbose_name="Add Comment")
   art = models.ForeignKey(article, on_delete = models.CASCADE)
habib
  • 43
  • 1
  • 13

1 Answers1

0

In Your view using this to sort in Descending order

Comm = comment.objects.order_by('-id')