Trying to modify a Django project's filter.
I have the following query
queryset = Post.objects.filter(public=True)
I want to modify this to have the query ordered by 'like_count'
How would I implement this?
通过使用order_by
,像这样:
q = Post.objects.filter(public=True).order_by('like_count')
If Like
is a different table.
The solution in the below link might help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.