Y
Y
y_o_l_k_i_n___e_g_o_r2021-05-28 07:53:39
Django
y_o_l_k_i_n___e_g_o_r, 2021-05-28 07:53:39

How to sort comment model by likes?

There is a comment model with a likes field.

class Comment(models.Model):
    likes = models.IntegerField()


How to sort the objects of this model by the number of likes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2021-05-28
@y_o_l_k_i_n___e_g_o_r

Comment.objects.order_by('likes')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question