From d830bad42123ea9c900a3fa38ea8460b9acecb64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Fri, 24 Nov 2017 14:47:36 -0500 Subject: [PATCH] Move global pagination setting away from quickstart section --- docs/tutorial/5-relationships-and-hyperlinked-apis.md | 5 +++-- docs/tutorial/quickstart.md | 7 +------ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/docs/tutorial/5-relationships-and-hyperlinked-apis.md b/docs/tutorial/5-relationships-and-hyperlinked-apis.md index b97e718bf..1e4da788e 100644 --- a/docs/tutorial/5-relationships-and-hyperlinked-apis.md +++ b/docs/tutorial/5-relationships-and-hyperlinked-apis.md @@ -134,13 +134,14 @@ After adding all those names into our URLconf, our final `snippets/urls.py` file The list views for users and code snippets could end up returning quite a lot of instances, so really we'd like to make sure we paginate the results, and allow the API client to step through each of the individual pages. -We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting: +We can change the default list style to use pagination, by modifying our `tutorial/settings.py` file slightly. Add the following setting: REST_FRAMEWORK = { + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 10 } -Note that settings in REST framework are all namespaced into a single dictionary setting, named 'REST_FRAMEWORK', which helps keep them well separated from your other project settings. +Note that settings in REST framework are all namespaced into a single dictionary setting, named `REST_FRAMEWORK`, which helps keep them well separated from your other project settings. We could also customize the pagination style if we needed too, but in this case we'll just stick with the default. diff --git a/docs/tutorial/quickstart.md b/docs/tutorial/quickstart.md index de2608323..ab789518d 100644 --- a/docs/tutorial/quickstart.md +++ b/docs/tutorial/quickstart.md @@ -134,18 +134,13 @@ Finally, we're including default login and logout views for use with the browsab ## Settings -We'd also like to set a few global settings. We'd like to turn on pagination, and we want our API to only be accessible to admin users. The settings module will be in `tutorial/settings.py` +Add `'rest_framework'` to `INSTALLED_APPS`. The settings module will be in `tutorial/settings.py` INSTALLED_APPS = ( ... 'rest_framework', ) - REST_FRAMEWORK = { - 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', - 'PAGE_SIZE': 10 - } - Okay, we're done. ---