Skip to content

Commit 95d4843

Browse files
authored
Fix Django 3.0 deprecations (#7074)
1 parent 4d9f9eb commit 95d4843

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

rest_framework/fields.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
parse_date, parse_datetime, parse_duration, parse_time
2424
)
2525
from django.utils.duration import duration_string
26-
from django.utils.encoding import is_protected_type, smart_text
26+
from django.utils.encoding import is_protected_type, smart_str
2727
from django.utils.formats import localize_input, sanitize_separators
2828
from django.utils.ipv6 import clean_ipv6_address
2929
from django.utils.timezone import utc
@@ -1082,7 +1082,7 @@ def to_internal_value(self, data):
10821082
instance.
10831083
"""
10841084

1085-
data = smart_text(data).strip()
1085+
data = smart_str(data).strip()
10861086

10871087
if self.localize:
10881088
data = sanitize_separators(data)

rest_framework/relations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from django.db.models import Manager
77
from django.db.models.query import QuerySet
88
from django.urls import NoReverseMatch, Resolver404, get_script_prefix, resolve
9-
from django.utils.encoding import smart_text, uri_to_iri
9+
from django.utils.encoding import smart_str, uri_to_iri
1010
from django.utils.translation import gettext_lazy as _
1111

1212
from rest_framework.fields import (
@@ -452,7 +452,7 @@ def to_internal_value(self, data):
452452
try:
453453
return self.get_queryset().get(**{self.slug_field: data})
454454
except ObjectDoesNotExist:
455-
self.fail('does_not_exist', slug_name=self.slug_field, value=smart_text(data))
455+
self.fail('does_not_exist', slug_name=self.slug_field, value=smart_str(data))
456456
except (TypeError, ValueError):
457457
self.fail('invalid')
458458

rest_framework/schemas/inspectors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import re
77
from weakref import WeakKeyDictionary
88

9-
from django.utils.encoding import smart_text
9+
from django.utils.encoding import smart_str
1010

1111
from rest_framework.settings import api_settings
1212
from rest_framework.utils import formatting
@@ -82,7 +82,7 @@ def get_description(self, path, method):
8282
method_docstring = getattr(view, method_name, None).__doc__
8383
if method_docstring:
8484
# An explicit docstring on the method or action.
85-
return self._get_description_section(view, method.lower(), formatting.dedent(smart_text(method_docstring)))
85+
return self._get_description_section(view, method.lower(), formatting.dedent(smart_str(method_docstring)))
8686
else:
8787
return self._get_description_section(view, getattr(view, 'action', method.lower()),
8888
view.get_view_description())

rest_framework/schemas/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
See schemas.__init__.py for package overview.
55
"""
66
from django.db import models
7-
from django.utils.translation import ugettext_lazy as _
7+
from django.utils.translation import gettext_lazy as _
88

99
from rest_framework.mixins import RetrieveModelMixin
1010

rest_framework/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from django.http import Http404
88
from django.http.response import HttpResponseBase
99
from django.utils.cache import cc_delim_re, patch_vary_headers
10-
from django.utils.encoding import smart_text
10+
from django.utils.encoding import smart_str
1111
from django.views.decorators.csrf import csrf_exempt
1212
from django.views.generic import View
1313

@@ -56,7 +56,7 @@ def get_view_description(view, html=False):
5656
if description is None:
5757
description = view.__class__.__doc__ or ''
5858

59-
description = formatting.dedent(smart_text(description))
59+
description = formatting.dedent(smart_str(description))
6060
if html:
6161
return formatting.markup_description(description)
6262
return description

0 commit comments

Comments
 (0)