Skip to content

Commit 51b9946

Browse files
committed
rename JSONAPIDjangoFilter to DjangoFilterBackend.
Per discussion about naming, the idea is that it should be easy to updgrade from DRF to DJA by simply changing some imports, retaining the same DRF (or in this case, django-filter) class names that are extended by DJA. see #467 (comment)
1 parent db9e1f9 commit 51b9946

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

docs/usage.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ REST_FRAMEWORK = {
3434
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
3535
'DEFAULT_FILTER_BACKENDS': (
3636
'rest_framework_json_api.filters.JSONAPIOrderingFilter',
37-
'rest_framework_json_api.filters.JSONAPIDjangoFilter',
37+
'rest_framework_json_api.filters.DjangoFilterBackend',
3838
),
3939
'TEST_REQUEST_RENDERER_CLASSES': (
4040
'rest_framework_json_api.renderers.JSONRenderer',
@@ -119,8 +119,8 @@ field name and the other two are not valid:
119119
If you want to silently ignore bad sort fields, just use `rest_framework.filters.OrderingFilter` and set
120120
`ordering_param` to `sort`.
121121

122-
#### `JSONAPIDjangoFilter`
123-
`JSONAPIDjangoFilter` implements a Django ORM-style [JSON:API `filter`](http://jsonapi.org/format/#fetching-filtering)
122+
#### `DjangoFilterBackend`
123+
`DjangoFilterBackend` implements a Django ORM-style [JSON:API `filter`](http://jsonapi.org/format/#fetching-filtering)
124124
using the [django-filter](https://django-filter.readthedocs.io/) package.
125125

126126
This filter is not part of the JSON:API standard per-se, other than the requirement
@@ -176,7 +176,7 @@ from rest_framework_json_api import filters
176176
class MyViewset(ModelViewSet):
177177
queryset = MyModel.objects.all()
178178
serializer_class = MyModelSerializer
179-
filter_backends = (filters.JSONAPIOrderingFilter, filters.JSONAPIDjangoFilter,)
179+
filter_backends = (filters.JSONAPIOrderingFilter, filters.DjangoFilterBackend,)
180180
```
181181

182182

example/settings/dev.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
'DEFAULT_METADATA_CLASS': 'rest_framework_json_api.metadata.JSONAPIMetadata',
9292
'DEFAULT_FILTER_BACKENDS': (
9393
'rest_framework_json_api.filters.JSONAPIOrderingFilter',
94-
'rest_framework_json_api.filters.JSONAPIDjangoFilter',
94+
'rest_framework_json_api.filters.DjangoFilterBackend',
9595
),
9696
'TEST_REQUEST_RENDERER_CLASSES': (
9797
'rest_framework_json_api.renderers.JSONRenderer',

rest_framework_json_api/filters/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
from .sort import JSONAPIOrderingFilter # noqa: F401
33
# If django-filter is not installed, no-op.
44
if pkgutil.find_loader('django_filters') is not None:
5-
from .filter import JSONAPIDjangoFilter # noqa: F401
5+
from .django_filter import DjangoFilterBackend # noqa: F401
66
del pkgutil

rest_framework_json_api/filters/filter.py renamed to rest_framework_json_api/filters/django_filter.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from rest_framework_json_api.utils import format_value
99

1010

11-
class JSONAPIDjangoFilter(DjangoFilterBackend):
11+
class DjangoFilterBackend(DjangoFilterBackend):
1212
"""
1313
A Django-style ORM filter implementation, using `django-filter`.
1414
@@ -110,7 +110,7 @@ def filter_queryset(self, request, queryset, view):
110110
"""
111111
# TODO: remove when Python 2.7 support is deprecated
112112
if VERSION >= (2, 0, 0):
113-
return super(JSONAPIDjangoFilter, self).filter_queryset(request, queryset, view)
113+
return super(DjangoFilterBackend, self).filter_queryset(request, queryset, view)
114114

115115
filter_class = self.get_filter_class(view, queryset)
116116

0 commit comments

Comments
 (0)