diff --git a/docs/api-guide/settings.md b/docs/api-guide/settings.md index ea150e10f..4d4898e1a 100644 --- a/docs/api-guide/settings.md +++ b/docs/api-guide/settings.md @@ -153,7 +153,7 @@ See the pagination documentation for further guidance on [setting the pagination --- -**This setting is pending deprecation.** +**This setting has been removed.** See the pagination documentation for further guidance on [setting the pagination style](pagination.md#modifying-the-pagination-style). diff --git a/docs/topics/3.8-announcement.md b/docs/topics/3.8-announcement.md index fededf72e..734f90e10 100644 --- a/docs/topics/3.8-announcement.md +++ b/docs/topics/3.8-announcement.md @@ -56,7 +56,26 @@ Alternatively you may override `save()` or `create()` or `update()` on the seria ## Deprecations -TODO +### `action` decorator replaces `list_route` and `detail_route` + +[#5705][gh5705] `list_route` and `detail_route` have been merge into a single `action` decorator. This improves viewset action introspection, and will allow extra actions to be displayed in the Browsable API in future versions. + +Both `list_route` and `detail_route` are now pending deprecation. They will be deprecated in 3.9 and removed entirely +in 3.10. + +The new `action` decorator takes a boolean `detail` argument. + +* Replace `detail_route` uses with `@action(detail=True)`. +* Replace `list_route` uses with `@action(detail=False)`. + + +### `exclude_from_schema` + +Both `APIView.exclude_from_schema` and the `exclude_from_schema` argument to the `@api_view` decorator are now deprecated. They will be removed entirely in 3.9. + +For `APIView` you should instead set a `schema = None` attribute on the view class. + +For function based views the `@schema` decorator can be used to exclude the view from the schema, by using `@schema(None)`. --- @@ -72,3 +91,5 @@ TODO [funding]: funding.md [gh5886]: https://github.com/encode/django-rest-framework/issues/5886 +[gh5705]: https://github.com/encode/django-rest-framework/issues/5705 + diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 62afa0597..e3428ef5b 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -78,9 +78,9 @@ def api_view(http_method_names=None, exclude_from_schema=False): if exclude_from_schema: warnings.warn( - "The `exclude_from_schema` argument to `api_view` is pending deprecation. " + "The `exclude_from_schema` argument to `api_view` is deprecated. " "Use the `schema` decorator instead, passing `None`.", - PendingDeprecationWarning + DeprecationWarning ) WrappedAPIView.exclude_from_schema = exclude_from_schema diff --git a/rest_framework/schemas/generators.py b/rest_framework/schemas/generators.py index 880777918..629f92b0d 100644 --- a/rest_framework/schemas/generators.py +++ b/rest_framework/schemas/generators.py @@ -208,10 +208,10 @@ class EndpointEnumerator(object): return False # Ignore anything except REST framework views. if hasattr(callback.cls, 'exclude_from_schema'): - fmt = ("The `{}.exclude_from_schema` attribute is pending deprecation. " + fmt = ("The `{}.exclude_from_schema` attribute is deprecated. " "Set `schema = None` instead.") msg = fmt.format(callback.cls.__name__) - warnings.warn(msg, PendingDeprecationWarning) + warnings.warn(msg, DeprecationWarning) if getattr(callback.cls, 'exclude_from_schema', False): return False diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 267c44585..081cb809d 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -871,15 +871,15 @@ class SchemaGenerationExclusionTests(TestCase): assert should_include == expected def test_deprecations(self): - with pytest.warns(PendingDeprecationWarning) as record: + with pytest.warns(DeprecationWarning) as record: @api_view(["GET"], exclude_from_schema=True) def view(request): pass assert len(record) == 1 assert str(record[0].message) == ( - "The `exclude_from_schema` argument to `api_view` is pending " - "deprecation. Use the `schema` decorator instead, passing `None`." + "The `exclude_from_schema` argument to `api_view` is deprecated. " + "Use the `schema` decorator instead, passing `None`." ) class OldFashionedExcludedView(APIView): @@ -893,13 +893,13 @@ class SchemaGenerationExclusionTests(TestCase): ] inspector = EndpointEnumerator(patterns) - with pytest.warns(PendingDeprecationWarning) as record: + with pytest.warns(DeprecationWarning) as record: inspector.get_api_endpoints() assert len(record) == 1 assert str(record[0].message) == ( "The `OldFashionedExcludedView.exclude_from_schema` attribute is " - "pending deprecation. Set `schema = None` instead." + "deprecated. Set `schema = None` instead." )