django REST框架错误:无法导入名称'PaginationSerializer'

val*_*far 1 django django-rest-framework

我的django框架在导入'PaginationSerializer'时抛出错误.知道什么可能出错吗?请在下面找到引发错误的行.我正在使用django REST框架3.1发布.

    from rest_framework.pagination import PaginationSerializer
Run Code Online (Sandbox Code Playgroud)

以下是错误输出.

    ImportError at /

    cannot import name 'PaginationSerializer'

    Request Method:     GET
    Request URL:    http://127.0.0.1:3434/
    Django Version:     1.8.2
    Exception Type:     ImportError
    Exception Value:    cannot import name 'PaginationSerializer'
    Exception Location:     /home/djangoDevelopment/test.git/rest_peace/urls.py in <module>, line 9
    Python Executable:  /home/pulak/djangoDevelopment/django-test.git/djenv/bin/python
    Python Version:     3.4.3
Run Code Online (Sandbox Code Playgroud)

Rah*_*pta 10

PaginationSerializer已在DRF 3.1版本中删除.分页API经历了很多变化,使其更易于使用,而且功能更强大.

现在,PaginationSerializer您需要覆盖该get_paginated_response()函数,而不是使用它.

根据API 中DRF 3.1中公布的更改Pagination:

pagination_serializer_class视图属性和 DEFAULT_PAGINATION_SERIALIZER_CLASS设置键不再有效.分页API不使用序列化程序来确定输出格式,您需要覆盖get_paginated_response 分页类上的方法,以指定输出格式的控制方式.