有没有一种方法可以在获取切片后重新排序Django查询?在
我正在尝试执行以下操作,但出现以下错误:Cannot reorder a query once a slice has been taken.
模型.py:
class PhotoManager(models.Manager):
def most_commented(self):
return super(PhotoManager, self).get_queryset().annotate(
the_count=(Count('comment'))).order_by('-the_count')[:100]
视图.py:
^{pr2}$我的目标是获取前100个评论最多的图片,然后随机排列它们的显示顺序。在
提前谢谢你!在
将照片转换为列表,然后正常洗牌:
相关问题 更多 >
编程相关推荐