You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a recipe model and i need create a view for most commented recipes, i'm using django-disqus for handling recipe's comments, but i don't know how can i order the queryset by the recipe's comment number.
class PopRecipeListView(GlobalQueryMixin, ListView):
model = Recipe
context_object_name = "recipe_list"
template_name = 'recipe/recipe_top_list.html'
def get_queryset(self):
qs = super(PopRecipeListView, self).get_queryset()
if qs:
qs = qs.extra(
select={
'comments': # get comment numbers
}
).filter(shared=True).order_by('-rate')[:20]
return qs
I have a
recipe
model and i need create a view for most commented recipes, i'm usingdjango-disqus
for handling recipe's comments, but i don't know how can i order the queryset by the recipe's comment number.Question here.
What's the properly way?
The text was updated successfully, but these errors were encountered: