直播视频app源码,实现直播内容自定义分页的效果
直播视频app源码,实现直播内容自定义分页的效果
1.自定义分类类,注意继承:
from rest_framework.pagination import PageNumberPagination
class LucasResultsSetPagination(PageNumberPagination):
page_size = 15
page_size_query_param = 'page_size'
max_page_size = 100
def get_paginated_response(self, data):
code = LucasConst.RES_OK
msg = 'success'
if not data:
code = LucasConst.RES_ERROR
msg = "data not found"
return Response(OrderedDict([
('code', code),
('msg', msg),
# ('count', self.count),
('next', self.get_next_link()),
# ('previous', self.get_previous_link()),
('weibo_array', data),
]))
2. 设置settings文件里的内容:
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
# 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
],
'DEFAULT_PAGINATION_CLASS': 'YanCommon.YanUtils.MyPagination.LucasResultsSetPagination',
'PAGE_SIZE': 15 # 每页数目
}
以上就是直播视频app源码,实现直播内容自定义分页的效果, 更多内容欢迎关注之后的文章