问题描述
我使用了 Django 休息框架中提到的自定义分页。在那,我不得不使用我的项目名称来提供CustomPagination的路径,但每次都说找不到模块。
然后我在视图中手动导入分页文件。它确实有效,但我的分页链接显示为空。我已经把图片贴在这里了。
我的观点:
from .pagination import CustomPagination
class ProductAPIView(ListAPIView):
permission_classes = [AllowAny]
queryset = Product.objects.all()
serializer_class = ProductSerializer
filterset_class = ProductFilter
pagination_class = CustomPagination
我的 pagination.py 文件
class CustomPagination(PageNumberPagination):
def get_paginated_response(self,data):
return Response({
'links': {
'next': self.get_next_link(),'prevIoUs': self.get_prevIoUs_link()
},'count': self.page.paginator.count,'results': data
})
我的设置文件:
# 'DEFAULT_PAGINATION_CLASS': 'RupSEOnline.core.pagination.CustomPagination','PAGE_SIZE': 100,
我已注释掉分页类并在视图中手动导入它,因为它说找不到模块。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)