Skip to content

Commit 973ba17

Browse files
author
zmrenwu
committed
Step5: 分页
1 parent bdaba48 commit 973ba17

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ $ git clone https://github.com/HelloGitHub-Team/HelloDjango-REST-framework-tutor
193193
4. [实现博客首页文章列表 API](https://www.zmrenwu.com/courses/django-rest-framework-tutorial/materials/93/)
194194
5. [用类视图实现首页 API](https://www.zmrenwu.com/courses/django-rest-framework-tutorial/materials/94/)
195195
6. [使用视图集简化代码](https://www.zmrenwu.com/courses/django-rest-framework-tutorial/materials/95/)
196+
7. [分页](https://www.zmrenwu.com/courses/django-rest-framework-tutorial/materials/96/)
196197

197198
## 公众号
198199
<p align="center">

blogproject/settings/common.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,9 @@
135135
# django-rest-framework
136136
# ------------------------------------------------------------------------------
137137
REST_FRAMEWORK = {
138+
# 设置 DEFAULT_PAGINATION_CLASS 后,将全局启用分页,所有 List 接口的返回结果都会被分页。
139+
# 如果想单独控制每个接口的分页情况,可不设置这个选项,而是在视图函数中进行配置
140+
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
141+
# 这个选项控制分页后每页的资源个数
138142
"PAGE_SIZE": 10,
139143
}

0 commit comments

Comments
 (0)