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?
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')