You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-guide/filtering.md
+1-52Lines changed: 1 addition & 52 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -221,7 +221,7 @@ By default, the search parameter is named `'search`', but this may be overridden
221
221
To dynamically change search fields based on request content, it's possible to subclass the `SearchFilter` and override the `get_search_fields()` function. For example, the following subclass will only search on `title` if the query parameter `title_only` is in the request:
222
222
223
223
from rest_framework import filters
224
-
224
+
225
225
class CustomSearchFilter(filters.SearchFilter):
226
226
def get_search_fields(self, view, request):
227
227
if request.query_params.get('title_only'):
@@ -291,53 +291,6 @@ The `ordering` attribute may be either a string or a list/tuple of strings.
291
291
292
292
---
293
293
294
-
## DjangoObjectPermissionsFilter
295
-
296
-
The `DjangoObjectPermissionsFilter` is intended to be used together with the [`django-guardian`][guardian] package, with custom `'view'` permissions added. The filter will ensure that querysets only returns objects for which the user has the appropriate view permission.
297
-
298
-
---
299
-
300
-
**Note:** This filter has been deprecated as of version 3.9 and moved to the 3rd-party [`djangorestframework-guardian` package][django-rest-framework-guardian].
301
-
302
-
---
303
-
304
-
If you're using `DjangoObjectPermissionsFilter`, you'll probably also want to add an appropriate object permissions class, to ensure that users can only operate on instances if they have the appropriate object permissions. The easiest way to do this is to subclass `DjangoObjectPermissions` and add `'view'` permissions to the `perms_map` attribute.
305
-
306
-
A complete example using both `DjangoObjectPermissionsFilter` and `DjangoObjectPermissions` might look something like this.
307
-
308
-
**permissions.py**:
309
-
310
-
class CustomObjectPermissions(permissions.DjangoObjectPermissions):
311
-
"""
312
-
Similar to `DjangoObjectPermissions`, but adding 'view' permissions.
For more information on adding `'view'` permissions for models, see the [relevant section][view-permissions] of the `django-guardian` documentation, and [this blogpost][view-permissions-blogpost].
338
-
339
-
---
340
-
341
294
# Custom generic filtering
342
295
343
296
You can also provide your own generic filtering backend, or write an installable app for other developers to use.
@@ -399,12 +352,8 @@ The [djangorestframework-word-filter][django-rest-framework-word-search-filter]
Copy file name to clipboardExpand all lines: docs/community/third-party-packages.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
246
246
*[djangorestframework-chain][djangorestframework-chain] - Allows arbitrary chaining of both relations and lookup filters.
247
247
*[django-url-filter][django-url-filter] - Allows a safe way to filter data via human-friendly URLs. It is a generic library which is not tied to DRF but it provides easy integration with DRF.
248
248
*[drf-url-filter][drf-url-filter] is a simple Django app to apply filters on drf `ModelViewSet`'s `Queryset` in a clean, simple and configurable way. It also supports validations on incoming query params and their values.
249
+
*[django-rest-framework-guardian][django-rest-framework-guardian] - Provides integration with django-guardian, including the `DjangoObjectPermissionsFilter` previously found in DRF.
249
250
250
251
### Misc
251
252
@@ -346,3 +347,4 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
0 commit comments