diff --git a/rest_framework/__init__.py b/rest_framework/__init__.py
index cc24ce46c5..b9e3f9817c 100644
--- a/rest_framework/__init__.py
+++ b/rest_framework/__init__.py
@@ -13,7 +13,7 @@
__version__ = '3.14.0'
__author__ = 'Tom Christie'
__license__ = 'BSD 3-Clause'
-__copyright__ = 'Copyright 2011-2019 Encode OSS Ltd'
+__copyright__ = 'Copyright 2011-2023 Encode OSS Ltd'
# Version synonym
VERSION = __version__
@@ -31,3 +31,7 @@
class RemovedInDRF315Warning(DeprecationWarning):
pass
+
+
+class RemovedInDRF317Warning(PendingDeprecationWarning):
+ pass
diff --git a/rest_framework/filters.py b/rest_framework/filters.py
index 1ffd9edc02..17e6975eb4 100644
--- a/rest_framework/filters.py
+++ b/rest_framework/filters.py
@@ -3,6 +3,7 @@
returned by list views.
"""
import operator
+import warnings
from functools import reduce
from django.core.exceptions import ImproperlyConfigured
@@ -12,6 +13,7 @@
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
+from rest_framework import RemovedInDRF317Warning
from rest_framework.compat import coreapi, coreschema, distinct
from rest_framework.settings import api_settings
@@ -29,6 +31,8 @@ def filter_queryset(self, request, queryset, view):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return []
@@ -146,6 +150,8 @@ def to_html(self, request, queryset, view):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
@@ -306,6 +312,8 @@ def to_html(self, request, queryset, view):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
diff --git a/rest_framework/pagination.py b/rest_framework/pagination.py
index af508bef6d..ce87785472 100644
--- a/rest_framework/pagination.py
+++ b/rest_framework/pagination.py
@@ -4,6 +4,8 @@
"""
import contextlib
+import warnings
+
from base64 import b64decode, b64encode
from collections import namedtuple
from urllib import parse
@@ -15,6 +17,7 @@
from django.utils.encoding import force_str
from django.utils.translation import gettext_lazy as _
+from rest_framework import RemovedInDRF317Warning
from rest_framework.compat import coreapi, coreschema
from rest_framework.exceptions import NotFound
from rest_framework.response import Response
@@ -152,6 +155,8 @@ def get_results(self, data):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
return []
def get_schema_operation_parameters(self, view):
@@ -311,6 +316,8 @@ def to_html(self):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
@@ -525,6 +532,8 @@ def get_count(self, queryset):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
return [
coreapi.Field(
@@ -930,6 +939,8 @@ def to_html(self):
def get_schema_fields(self, view):
assert coreapi is not None, 'coreapi must be installed to use `get_schema_fields()`'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema is not None, 'coreschema must be installed to use `get_schema_fields()`'
fields = [
coreapi.Field(
diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py
index 0a3b03729d..db1fdd128b 100644
--- a/rest_framework/renderers.py
+++ b/rest_framework/renderers.py
@@ -9,6 +9,7 @@
import base64
import contextlib
+import datetime
from urllib import parse
from django import forms
@@ -1062,6 +1063,7 @@ class Dumper(yaml.Dumper):
def ignore_aliases(self, data):
return True
Dumper.add_representer(SafeString, Dumper.represent_str)
+ Dumper.add_representer(datetime.timedelta, encoders.CustomScalar.represent_timedelta)
return yaml.dump(data, default_flow_style=False, sort_keys=False, Dumper=Dumper).encode('utf-8')
diff --git a/rest_framework/schemas/coreapi.py b/rest_framework/schemas/coreapi.py
index 0713e0cb80..582aba196e 100644
--- a/rest_framework/schemas/coreapi.py
+++ b/rest_framework/schemas/coreapi.py
@@ -5,7 +5,7 @@
from django.db import models
from django.utils.encoding import force_str
-from rest_framework import exceptions, serializers
+from rest_framework import RemovedInDRF317Warning, exceptions, serializers
from rest_framework.compat import coreapi, coreschema, uritemplate
from rest_framework.settings import api_settings
@@ -118,6 +118,8 @@ class SchemaGenerator(BaseSchemaGenerator):
def __init__(self, title=None, url=None, description=None, patterns=None, urlconf=None, version=None):
assert coreapi, '`coreapi` must be installed for schema support.'
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
assert coreschema, '`coreschema` must be installed for schema support.'
super().__init__(title, url, description, patterns, urlconf)
@@ -351,6 +353,9 @@ def __init__(self, manual_fields=None):
will be added to auto-generated fields, overwriting on `Field.name`
"""
super().__init__()
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
+
if manual_fields is None:
manual_fields = []
self._manual_fields = manual_fields
@@ -592,6 +597,9 @@ def __init__(self, fields, description='', encoding=None):
* `description`: String description for view. Optional.
"""
super().__init__()
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
+
assert all(isinstance(f, coreapi.Field) for f in fields), "`fields` must be a list of coreapi.Field instances"
self._fields = fields
self._description = description
@@ -613,4 +621,6 @@ def get_link(self, path, method, base_url):
def is_enabled():
"""Is CoreAPI Mode enabled?"""
+ if coreapi is not None:
+ warnings.warn('CoreAPI compatibility is deprecated and will be removed in DRF 3.17', RemovedInDRF317Warning)
return issubclass(api_settings.DEFAULT_SCHEMA_CLASS, AutoSchema)
diff --git a/rest_framework/templates/rest_framework/horizontal/select_multiple.html b/rest_framework/templates/rest_framework/horizontal/select_multiple.html
index 36ff9fd0dc..12e781cc65 100644
--- a/rest_framework/templates/rest_framework/horizontal/select_multiple.html
+++ b/rest_framework/templates/rest_framework/horizontal/select_multiple.html
@@ -11,7 +11,7 @@
{% endif %}