mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-25 11:04:02 +03:00
Upgrade pending deprecations to deprecations
This commit is contained in:
parent
1d4956f616
commit
1f99612845
|
@ -173,6 +173,16 @@ Thanks go to the latest member of our maintenance team, [José Padilla](https://
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Deprecations
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## What's next?
|
## What's next?
|
||||||
|
|
||||||
The next focus will be on HTML renderings of API output and will include:
|
The next focus will be on HTML renderings of API output and will include:
|
||||||
|
|
|
@ -219,8 +219,8 @@ class Request(object):
|
||||||
Synonym for `.query_params`, for backwards compatibility.
|
Synonym for `.query_params`, for backwards compatibility.
|
||||||
"""
|
"""
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"`request.QUERY_PARAMS` is pending deprecation. Use `request.query_params` instead.",
|
"`request.QUERY_PARAMS` is deprecated. Use `request.query_params` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=1
|
stacklevel=1
|
||||||
)
|
)
|
||||||
return self._request.GET
|
return self._request.GET
|
||||||
|
@ -240,8 +240,8 @@ class Request(object):
|
||||||
arbitrary parsers, and also works on methods other than POST (eg PUT).
|
arbitrary parsers, and also works on methods other than POST (eg PUT).
|
||||||
"""
|
"""
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"`request.DATA` is pending deprecation. Use `request.data` instead.",
|
"`request.DATA` is deprecated. Use `request.data` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=1
|
stacklevel=1
|
||||||
)
|
)
|
||||||
if not _hasattr(self, '_data'):
|
if not _hasattr(self, '_data'):
|
||||||
|
@ -257,8 +257,8 @@ class Request(object):
|
||||||
arbitrary parsers, and also works on methods other than POST (eg PUT).
|
arbitrary parsers, and also works on methods other than POST (eg PUT).
|
||||||
"""
|
"""
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"`request.FILES` is pending deprecation. Use `request.data` instead.",
|
"`request.FILES` is deprecated. Use `request.data` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=1
|
stacklevel=1
|
||||||
)
|
)
|
||||||
if not _hasattr(self, '_files'):
|
if not _hasattr(self, '_files'):
|
||||||
|
|
|
@ -1103,9 +1103,9 @@ class ModelSerializer(Serializer):
|
||||||
write_only_fields = getattr(self.Meta, 'write_only_fields', None)
|
write_only_fields = getattr(self.Meta, 'write_only_fields', None)
|
||||||
if write_only_fields is not None:
|
if write_only_fields is not None:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The `Meta.write_only_fields` option is pending deprecation. "
|
"The `Meta.write_only_fields` option is deprecated. "
|
||||||
"Use `Meta.extra_kwargs={<field_name>: {'write_only': True}}` instead.",
|
"Use `Meta.extra_kwargs={<field_name>: {'write_only': True}}` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=3
|
stacklevel=3
|
||||||
)
|
)
|
||||||
for field_name in write_only_fields:
|
for field_name in write_only_fields:
|
||||||
|
@ -1116,9 +1116,9 @@ class ModelSerializer(Serializer):
|
||||||
view_name = getattr(self.Meta, 'view_name', None)
|
view_name = getattr(self.Meta, 'view_name', None)
|
||||||
if view_name is not None:
|
if view_name is not None:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The `Meta.view_name` option is pending deprecation. "
|
"The `Meta.view_name` option is deprecated. "
|
||||||
"Use `Meta.extra_kwargs={'url': {'view_name': ...}}` instead.",
|
"Use `Meta.extra_kwargs={'url': {'view_name': ...}}` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=3
|
stacklevel=3
|
||||||
)
|
)
|
||||||
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
|
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
|
||||||
|
@ -1128,9 +1128,9 @@ class ModelSerializer(Serializer):
|
||||||
lookup_field = getattr(self.Meta, 'lookup_field', None)
|
lookup_field = getattr(self.Meta, 'lookup_field', None)
|
||||||
if lookup_field is not None:
|
if lookup_field is not None:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
"The `Meta.lookup_field` option is pending deprecation. "
|
"The `Meta.lookup_field` option is deprecated. "
|
||||||
"Use `Meta.extra_kwargs={'url': {'lookup_field': ...}}` instead.",
|
"Use `Meta.extra_kwargs={'url': {'lookup_field': ...}}` instead.",
|
||||||
PendingDeprecationWarning,
|
DeprecationWarning,
|
||||||
stacklevel=3
|
stacklevel=3
|
||||||
)
|
)
|
||||||
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
|
kwargs = extra_kwargs.get(api_settings.URL_FIELD_NAME, {})
|
||||||
|
|
|
@ -409,7 +409,7 @@ class APIView(View):
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
'The `exception_handler(exc)` call signature is deprecated. '
|
'The `exception_handler(exc)` call signature is deprecated. '
|
||||||
'Use `exception_handler(exc, context) instead.',
|
'Use `exception_handler(exc, context) instead.',
|
||||||
PendingDeprecationWarning
|
DeprecationWarning
|
||||||
)
|
)
|
||||||
response = exception_handler(exc)
|
response = exception_handler(exc)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user