@@ -33,7 +33,7 @@ REST_FRAMEWORK = {
3333 ),
3434 ' DEFAULT_METADATA_CLASS' : ' rest_framework_json_api.metadata.JSONAPIMetadata' ,
3535 ' DEFAULT_FILTER_BACKENDS' : (
36- ' rest_framework_json_api.backends .JSONAPIOrderingFilter' ,
36+ ' rest_framework_json_api.filters .JSONAPIOrderingFilter' ,
3737 ),
3838 ' TEST_REQUEST_RENDERER_CLASSES' : (
3939 ' rest_framework_json_api.renderers.JSONRenderer' ,
@@ -98,7 +98,7 @@ _This is the first of several anticipated JSON:API-specific filter backends._
9898` JSONAPIOrderingFilter ` implements the [ JSON: API ` sort ` ] ( http://jsonapi.org/format/#fetching-sorting ) and uses
9999DRF's [ ordering filter] ( http://django-rest-framework.readthedocs.io/en/latest/api-guide/filtering/#orderingfilter ) .
100100
101- Per the JSON: API , "If the server does not support sorting as specified in the query parameter ` sort ` ,
101+ Per the JSON: API specification , "If the server does not support sorting as specified in the query parameter ` sort ` ,
102102it ** MUST** return ` 400 Bad Request ` ." For example, for ` ?sort= ` abc,foo,def` where ` foo` is a valid
103103field name and the other two are not valid:
104104``` json
@@ -118,6 +118,20 @@ field name and the other two are not valid:
118118If you want to silently ignore bad sort fields, just use ` rest_framework.filters.OrderingFilter ` and set
119119` ordering_param ` to ` sort ` .
120120
121+ #### Configuring Filter Backends
122+
123+ You can configure the filter backends either by setting the ` REST_FRAMEWORK['DEFAULT_FILTER_BACKENDS'] ` as shown
124+ in the [ preceding] ( #configuration ) example or individually add them as ` .filter_backends ` View attributes:
125+
126+ ``` python
127+ from rest_framework_json_api import filters
128+
129+ class MyViewset (ModelViewSet ):
130+ queryset = MyModel.objects.all()
131+ serializer_class = MyModelSerializer
132+ filter_backends = (filters.JSONAPIOrderingFilter,)
133+ ```
134+
121135
122136### Performance Testing
123137
0 commit comments