Skip to content

Commit

Permalink
Fix Django 3.0 deprecations (encode#7074)
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkilby authored and sigvef committed Dec 3, 2022
1 parent 95f0ef0 commit 4ba5165
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions rest_framework/fields.py
Expand Up @@ -23,7 +23,7 @@
parse_date, parse_datetime, parse_duration, parse_time
)
from django.utils.duration import duration_string
from django.utils.encoding import is_protected_type, smart_text
from django.utils.encoding import is_protected_type, smart_str
from django.utils.formats import localize_input, sanitize_separators
from django.utils.ipv6 import clean_ipv6_address
from django.utils.timezone import utc
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def to_internal_value(self, data):
instance.
"""

data = smart_text(data).strip()
data = smart_str(data).strip()

if self.localize:
data = sanitize_separators(data)
Expand Down
4 changes: 2 additions & 2 deletions rest_framework/relations.py
Expand Up @@ -6,7 +6,7 @@
from django.db.models import Manager
from django.db.models.query import QuerySet
from django.urls import NoReverseMatch, Resolver404, get_script_prefix, resolve
from django.utils.encoding import smart_text, uri_to_iri
from django.utils.encoding import smart_str, uri_to_iri
from django.utils.translation import gettext_lazy as _

from rest_framework.fields import (
Expand Down Expand Up @@ -452,7 +452,7 @@ def to_internal_value(self, data):
try:
return self.get_queryset().get(**{self.slug_field: data})
except ObjectDoesNotExist:
self.fail('does_not_exist', slug_name=self.slug_field, value=smart_text(data))
self.fail('does_not_exist', slug_name=self.slug_field, value=smart_str(data))
except (TypeError, ValueError):
self.fail('invalid')

Expand Down
4 changes: 2 additions & 2 deletions rest_framework/schemas/inspectors.py
Expand Up @@ -6,7 +6,7 @@
import re
from weakref import WeakKeyDictionary

from django.utils.encoding import smart_text
from django.utils.encoding import smart_str

from rest_framework.settings import api_settings
from rest_framework.utils import formatting
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_description(self, path, method):
method_docstring = getattr(view, method_name, None).__doc__
if method_docstring:
# An explicit docstring on the method or action.
return self._get_description_section(view, method.lower(), formatting.dedent(smart_text(method_docstring)))
return self._get_description_section(view, method.lower(), formatting.dedent(smart_str(method_docstring)))
else:
return self._get_description_section(view, getattr(view, 'action', method.lower()),
view.get_view_description())
Expand Down
2 changes: 1 addition & 1 deletion rest_framework/schemas/utils.py
Expand Up @@ -4,7 +4,7 @@
See schemas.__init__.py for package overview.
"""
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from rest_framework.mixins import RetrieveModelMixin

Expand Down
4 changes: 2 additions & 2 deletions rest_framework/views.py
Expand Up @@ -7,7 +7,7 @@
from django.http import Http404
from django.http.response import HttpResponseBase
from django.utils.cache import cc_delim_re, patch_vary_headers
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View

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

description = formatting.dedent(smart_text(description))
description = formatting.dedent(smart_str(description))
if html:
return formatting.markup_description(description)
return description
Expand Down

0 comments on commit 4ba5165

Please sign in to comment.