from django.core.paginator import Paginator # 分页器
goods_comment_data = goods.ordergoodscomment_set.all().order_by('-score') # 未分页的数据集
if 'page' in body and 'size' in body:
page = body['page']
size = body['size']
paginator = Paginator(goods_comment_data, size)
goods_comment_data = paginator.page(page)
goods_comment_list = [goods_comment.json() for goods_comment in goods_comment_data]
网友评论