mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-06-14 10:33:17 +03:00
Merge pull request #2460 from mmarvick/master
Small fixes to the tutorial
This commit is contained in:
commit
235b98e427
|
@ -96,7 +96,7 @@ Notice that we're no longer explicitly tying our requests or responses to a give
|
||||||
|
|
||||||
## Adding optional format suffixes to our URLs
|
## Adding optional format suffixes to our URLs
|
||||||
|
|
||||||
To take advantage of the fact that our responses are no longer hardwired to a single content type let's add support for format suffixes to our API endpoints. Using format suffixes gives us URLs that explicitly refer to a given format, and means our API will be able to handle URLs such as [http://example.com/api/items/4.json][json-url].
|
To take advantage of the fact that our responses are no longer hardwired to a single content type let's add support for format suffixes to our API endpoints. Using format suffixes gives us URLs that explicitly refer to a given format, and means our API will be able to handle URLs such as [http://example.com/api/items/4/.json][json-url].
|
||||||
|
|
||||||
Start by adding a `format` keyword argument to both of the views, like so.
|
Start by adding a `format` keyword argument to both of the views, like so.
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ 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.
|
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 `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 = {
|
REST_FRAMEWORK = {
|
||||||
'PAGINATE_BY': 10
|
'PAGINATE_BY': 10
|
||||||
|
|
Loading…
Reference in New Issue
Block a user