Skip to content

Commit df1d146

Browse files
authored
Remove old documentation (#6765)
1 parent af2a2e6 commit df1d146

File tree

3 files changed

+5
-54
lines changed

3 files changed

+5
-54
lines changed

docs/api-guide/filtering.md

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ By default, the search parameter is named `'search`', but this may be overridden
221221
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:
222222

223223
from rest_framework import filters
224-
224+
225225
class CustomSearchFilter(filters.SearchFilter):
226226
def get_search_fields(self, view, request):
227227
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.
291291

292292
---
293293

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.
313-
"""
314-
perms_map = {
315-
'GET': ['%(app_label)s.view_%(model_name)s'],
316-
'OPTIONS': ['%(app_label)s.view_%(model_name)s'],
317-
'HEAD': ['%(app_label)s.view_%(model_name)s'],
318-
'POST': ['%(app_label)s.add_%(model_name)s'],
319-
'PUT': ['%(app_label)s.change_%(model_name)s'],
320-
'PATCH': ['%(app_label)s.change_%(model_name)s'],
321-
'DELETE': ['%(app_label)s.delete_%(model_name)s'],
322-
}
323-
324-
**views.py**:
325-
326-
class EventViewSet(viewsets.ModelViewSet):
327-
"""
328-
Viewset that only lists events if user has 'view' permissions, and only
329-
allows operations on individual events if user has appropriate 'view', 'add',
330-
'change' or 'delete' permissions.
331-
"""
332-
queryset = Event.objects.all()
333-
serializer_class = EventSerializer
334-
filter_backends = (filters.DjangoObjectPermissionsFilter,)
335-
permission_classes = (myapp.permissions.CustomObjectPermissions,)
336-
337-
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-
341294
# Custom generic filtering
342295

343296
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]
399352
[cite]: https://docs.djangoproject.com/en/stable/topics/db/queries/#retrieving-specific-objects-with-filters
400353
[django-filter-docs]: https://django-filter.readthedocs.io/en/latest/index.html
401354
[django-filter-drf-docs]: https://django-filter.readthedocs.io/en/latest/guide/rest_framework.html
402-
[guardian]: https://django-guardian.readthedocs.io/
403-
[view-permissions]: https://django-guardian.readthedocs.io/en/latest/userguide/assign.html
404-
[view-permissions-blogpost]: https://blog.nyaruka.com/adding-a-view-permission-to-django-models
405355
[search-django-admin]: https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.search_fields
406356
[django-rest-framework-filters]: https://github.com/philipn/django-rest-framework-filters
407-
[django-rest-framework-guardian]: https://github.com/rpkilby/django-rest-framework-guardian
408357
[django-rest-framework-word-search-filter]: https://github.com/trollknurr/django-rest-framework-word-search-filter
409358
[django-url-filter]: https://github.com/miki725/django-url-filter
410359
[drf-url-filter]: https://github.com/manjitkumar/drf-url-filters

docs/community/third-party-packages.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
246246
* [djangorestframework-chain][djangorestframework-chain] - Allows arbitrary chaining of both relations and lookup filters.
247247
* [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.
248248
* [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.
249250

250251
### Misc
251252

@@ -346,3 +347,4 @@ To submit new content, [open an issue][drf-create-issue] or [create a pull reque
346347
[drf-access-policy]: https://github.com/rsinger86/drf-access-policy
347348
[drf-flex-fields]: https://github.com/rsinger86/drf-flex-fields
348349
[djangorestframework-mvt]: https://github.com/corteva/djangorestframework-mvt
350+
[django-rest-framework-guardian]: https://github.com/rpkilby/django-rest-framework-guardian

rest_framework/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
for writing function-based views with REST framework.
44
55
There are also various decorators for setting the API policies on function
6-
based views, as well as the `@detail_route` and `@list_route` decorators, which are
7-
used to annotate methods on viewsets that should be included by routers.
6+
based views, as well as the `@action` decorator, which is used to annotate
7+
methods on viewsets that should be included by routers.
88
"""
99
import types
1010

0 commit comments

Comments
 (0)