Skip to content

Commit d4acf95

Browse files
committed
Update deprecations
1 parent cfa942f commit d4acf95

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

docs/api-guide/settings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ See the pagination documentation for further guidance on [setting the pagination
153153

154154
---
155155

156-
**This setting is pending deprecation.**
156+
**This setting has been removed.**
157157

158158
See the pagination documentation for further guidance on [setting the pagination style](pagination.md#modifying-the-pagination-style).
159159

docs/topics/3.8-announcement.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,26 @@ Alternatively you may override `save()` or `create()` or `update()` on the seria
5656

5757
## Deprecations
5858

59-
TODO
59+
### `action` decorator replaces `list_route` and `detail_route`
60+
61+
[#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.
62+
63+
Both `list_route` and `detail_route` are now pending deprecation. They will be deprecated in 3.9 and removed entirely
64+
in 3.10.
65+
66+
The new `action` decorator takes a boolean `detail` argument.
67+
68+
* Replace `detail_route` uses with `@action(detail=True)`.
69+
* Replace `list_route` uses with `@action(detail=False)`.
70+
71+
72+
### `exclude_from_schema`
73+
74+
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.
75+
76+
For `APIView` you should instead set a `schema = None` attribute on the view class.
77+
78+
For function based views the `@schema` decorator can be used to exclude the view from the schema, by using `@schema(None)`.
6079

6180
---
6281

@@ -72,3 +91,5 @@ TODO
7291

7392
[funding]: funding.md
7493
[gh5886]: https://github.com/encode/django-rest-framework/issues/5886
94+
[gh5705]: https://github.com/encode/django-rest-framework/issues/5705
95+

rest_framework/decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def handler(self, *args, **kwargs):
7878

7979
if exclude_from_schema:
8080
warnings.warn(
81-
"The `exclude_from_schema` argument to `api_view` is pending deprecation. "
81+
"The `exclude_from_schema` argument to `api_view` is deprecated. "
8282
"Use the `schema` decorator instead, passing `None`.",
83-
PendingDeprecationWarning
83+
DeprecationWarning
8484
)
8585
WrappedAPIView.exclude_from_schema = exclude_from_schema
8686

rest_framework/schemas/generators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ def should_include_endpoint(self, path, callback):
208208
return False # Ignore anything except REST framework views.
209209

210210
if hasattr(callback.cls, 'exclude_from_schema'):
211-
fmt = ("The `{}.exclude_from_schema` attribute is pending deprecation. "
211+
fmt = ("The `{}.exclude_from_schema` attribute is deprecated. "
212212
"Set `schema = None` instead.")
213213
msg = fmt.format(callback.cls.__name__)
214-
warnings.warn(msg, PendingDeprecationWarning)
214+
warnings.warn(msg, DeprecationWarning)
215215
if getattr(callback.cls, 'exclude_from_schema', False):
216216
return False
217217

tests/test_schemas.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,15 +871,15 @@ def test_should_include_endpoint_excludes_correctly(self):
871871
assert should_include == expected
872872

873873
def test_deprecations(self):
874-
with pytest.warns(PendingDeprecationWarning) as record:
874+
with pytest.warns(DeprecationWarning) as record:
875875
@api_view(["GET"], exclude_from_schema=True)
876876
def view(request):
877877
pass
878878

879879
assert len(record) == 1
880880
assert str(record[0].message) == (
881-
"The `exclude_from_schema` argument to `api_view` is pending "
882-
"deprecation. Use the `schema` decorator instead, passing `None`."
881+
"The `exclude_from_schema` argument to `api_view` is deprecated. "
882+
"Use the `schema` decorator instead, passing `None`."
883883
)
884884

885885
class OldFashionedExcludedView(APIView):
@@ -893,13 +893,13 @@ def get(self, request, *args, **kwargs):
893893
]
894894

895895
inspector = EndpointEnumerator(patterns)
896-
with pytest.warns(PendingDeprecationWarning) as record:
896+
with pytest.warns(DeprecationWarning) as record:
897897
inspector.get_api_endpoints()
898898

899899
assert len(record) == 1
900900
assert str(record[0].message) == (
901901
"The `OldFashionedExcludedView.exclude_from_schema` attribute is "
902-
"pending deprecation. Set `schema = None` instead."
902+
"deprecated. Set `schema = None` instead."
903903
)
904904

905905

0 commit comments

Comments
 (0)