Skip to content

Commit 1f99612

Browse files
committed
Upgrade pending deprecations to deprecations
1 parent 1d4956f commit 1f99612

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

docs/topics/3.1-announcement.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ Thanks go to the latest member of our maintenance team, [José Padilla](https://
173173

174174
---
175175

176+
## Deprecations
177+
178+
The `request.DATA`, `request.FILES` and `request.QUERY_PARAMS` attributes move from pending deprecation, to deprecated. Use `request.data` and `request.query_params` instead, as discussed in the 3.0 release notes.
179+
180+
The ModelSerializer Meta options for `write_only_fields`, `view_name` and `lookup_field` are also moved from pending deprecation, to deprecated. Use `extra_kwargs` instead, as discussed in the 3.0 release notes.
181+
182+
All these attributes and options will still work in 3.1, but their usage will raise a warning. They will be fully removed in 3.2.
183+
184+
---
185+
176186
## What's next?
177187

178188
The next focus will be on HTML renderings of API output and will include:

rest_framework/request.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ def QUERY_PARAMS(self):
219219
Synonym for `.query_params`, for backwards compatibility.
220220
"""
221221
warnings.warn(
222-
"`request.QUERY_PARAMS` is pending deprecation. Use `request.query_params` instead.",
223-
PendingDeprecationWarning,
222+
"`request.QUERY_PARAMS` is deprecated. Use `request.query_params` instead.",
223+
DeprecationWarning,
224224
stacklevel=1
225225
)
226226
return self._request.GET
@@ -240,8 +240,8 @@ def DATA(self):
240240
arbitrary parsers, and also works on methods other than POST (eg PUT).
241241
"""
242242
warnings.warn(
243-
"`request.DATA` is pending deprecation. Use `request.data` instead.",
244-
PendingDeprecationWarning,
243+
"`request.DATA` is deprecated. Use `request.data` instead.",
244+
DeprecationWarning,
245245
stacklevel=1
246246
)
247247
if not _hasattr(self, '_data'):
@@ -257,8 +257,8 @@ def FILES(self):
257257
arbitrary parsers, and also works on methods other than POST (eg PUT).
258258
"""
259259
warnings.warn(
260-
"`request.FILES` is pending deprecation. Use `request.data` instead.",
261-
PendingDeprecationWarning,
260+
"`request.FILES` is deprecated. Use `request.data` instead.",
261+
DeprecationWarning,
262262
stacklevel=1
263263
)
264264
if not _hasattr(self, '_files'):

rest_framework/serializers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,9 +1103,9 @@ def get_extra_kwargs(self):
11031103
write_only_fields = getattr(self.Meta, 'write_only_fields', None)
11041104
if write_only_fields is not None:
11051105
warnings.warn(
1106-
"The `Meta.write_only_fields` option is pending deprecation. "
1106+
"The `Meta.write_only_fields` option is deprecated. "
11071107
"Use `Meta.extra_kwargs={<field_name>: {'write_only': True}}` instead.",
1108-
PendingDeprecationWarning,
1108+
DeprecationWarning,
11091109
stacklevel=3
11101110
)
11111111
for field_name in write_only_fields:
@@ -1116,9 +1116,9 @@ def get_extra_kwargs(self):
11161116
view_name = getattr(self.Meta, 'view_name', None)
11171117
if view_name is not None:
11181118
warnings.warn(
1119-
"The `Meta.view_name` option is pending deprecation. "
1119+
"The `Meta.view_name` option is deprecated. "
11201120
"Use `Meta.extra_kwargs={'url': {'view_name': ...}}` instead.",
1121-
PendingDeprecationWarning,
1121+
DeprecationWarning,
11221122
stacklevel=3
11231123
)
11241124
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
@@ -1128,9 +1128,9 @@ def get_extra_kwargs(self):
11281128
lookup_field = getattr(self.Meta, 'lookup_field', None)
11291129
if lookup_field is not None:
11301130
warnings.warn(
1131-
"The `Meta.lookup_field` option is pending deprecation. "
1131+
"The `Meta.lookup_field` option is deprecated. "
11321132
"Use `Meta.extra_kwargs={'url': {'lookup_field': ...}}` instead.",
1133-
PendingDeprecationWarning,
1133+
DeprecationWarning,
11341134
stacklevel=3
11351135
)
11361136
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})

rest_framework/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ def handle_exception(self, exc):
409409
warnings.warn(
410410
'The `exception_handler(exc)` call signature is deprecated. '
411411
'Use `exception_handler(exc, context) instead.',
412-
PendingDeprecationWarning
412+
DeprecationWarning
413413
)
414414
response = exception_handler(exc)
415415
else:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy