问题描述
我的django框架在导入PaginationSerializer时引发错误。任何想法可能出了什么问题?请在下面找到抛出错误的行。我正在使用django REST框架3.1版本。
My django framework is throwing an error while importing 'PaginationSerializer'. Any idea what could have gone wrong? Please find below the line which throws the error. I am using django REST framework 3.1 release.
from rest_framework.pagination import PaginationSerializer
以下是错误输出。
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
推荐答案
PaginationSerializer
已在DRF 3.1发行版中删除。分页API经历了很多变化,使其更容易使用,更强大。
PaginationSerializer
was removed in DRF 3.1 release. The pagination API underwent a lot of changes, making it both easier to use, and more powerful.
现在,而不是使用 PaginationSerializer
,您需要覆盖 get_paginated_response()
函数。
Now, instead of using the PaginationSerializer
, you need to override the get_paginated_response()
function.
根据在DRF 3.1中,在分页
API:
As per the changes announced in DRF 3.1 in Pagination
API:
这篇关于django REST框架错误:无法导入名称“PaginationSerializer”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!