Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3fe349d

Browse files
author
Oliver Sauder
committed
Improve REST_FRAMEWORK settings recommendation
This includes: * Testing configuration as explained in http://www.django-rest-framework.org/api-guide/testing/#configuration * Sorting configuration according to http://jsonapi.org/format/#fetching-sorting
1 parent 2619f45 commit 3fe349d

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

‎CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[unreleased]
2+
3+
* Add testing configuration to `REST_FRAMEWORK` configuration as described in [DRF](http://www.django-rest-framework.org/api-guide/testing/#configuration)
4+
* Add sorting configuration to `REST_FRAMEWORK` as defined in [json api spec](http://jsonapi.org/format/#fetching-sorting)
5+
6+
17
v2.5.0 - Released July 11, 2018
28

39
* Add new pagination classes based on JSON:API query parameter *recommendations*:

‎README.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ override ``settings.REST_FRAMEWORK``
140140
'PAGE_SIZE': 10,
141141
'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
142142
'DEFAULT_PAGINATION_CLASS':
143-
'rest_framework_json_api.pagination.PageNumberPagination',
143+
'rest_framework_json_api.pagination.JsonApiPageNumberPagination',
144144
'DEFAULT_PARSER_CLASSES': (
145145
'rest_framework_json_api.parsers.JSONParser',
146146
'rest_framework.parsers.FormParser',
@@ -151,10 +151,14 @@ override ``settings.REST_FRAMEWORK``
151151
'rest_framework.renderers.BrowsableAPIRenderer',
152152
),
153153
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
154+
'DEFAULT_FILTER_BACKENDS': (
155+
'rest_framework.filters.OrderingFilter',
156+
),
157+
'ORDERING_PARAM': 'sort',
158+
'TEST_REQUEST_RENDERER_CLASSES': (
159+
'rest_framework_json_api.renderers.JSONRenderer',
160+
),
161+
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
154162
}
155163

156-
If ``PAGINATE_BY`` is set the renderer will return a ``meta`` object with
157-
record count and a ``links`` object with the next and previous links. Pages
158-
can be specified with the ``page`` GET parameter.
159-
160164
This package provides much more including automatic inflection of JSON keys, extra top level data (using nested serializers), relationships, links, and handy shortcuts like MultipleIDMixin. Read more at http://django-rest-framework-json-api.readthedocs.org/

‎docs/usage.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ REST_FRAMEWORK = {
3131
'rest_framework.renderers.BrowsableAPIRenderer'
3232
),
3333
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
34+
'DEFAULT_FILTER_BACKENDS': (
35+
'rest_framework.filters.OrderingFilter',
36+
),
37+
'ORDERING_PARAM': 'sort',
38+
'TEST_REQUEST_RENDERER_CLASSES': (
39+
'rest_framework_json_api.renderers.JSONRenderer',
40+
),
41+
'TEST_REQUEST_DEFAULT_FORMAT': 'vnd.api+json'
3442
}
3543
```
3644

‎example/settings/dev.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
'rest_framework.renderers.BrowsableAPIRenderer',
8989
),
9090
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
91+
'DEFAULT_FILTER_BACKENDS': (
92+
'rest_framework.filters.OrderingFilter',
93+
),
94+
'ORDERING_PARAM': 'sort',
9195
'TEST_REQUEST_RENDERER_CLASSES': (
9296
'rest_framework_json_api.renderers.JSONRenderer',
9397
),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /