[后端]修改后端公告GET接口,增加返回公告总条数,总页数

This commit is contained in:
sxw
2015-08-08 08:41:20 +08:00
parent a03b8af79d
commit fc57dcbde4
3 changed files with 13 additions and 5 deletions

View File

@@ -70,7 +70,11 @@ def paginate(request, query_set, object_serializer):
except Exception:
return error_response(u"参数错误")
data = {"results": object_serializer(current_page, many=True).data, "previous_page": None, "next_page": None}
data = {"results": object_serializer(current_page, many=True).data,
"previous_page": None,
"next_page": None,
"count": paginator.count,
"total_page": paginator.num_pages}
try:
data["previous_page"] = current_page.previous_page_number()
@@ -82,4 +86,4 @@ def paginate(request, query_set, object_serializer):
except Exception:
pass
return success_response(data)
return success_response(data)