Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Django 3.0 deprecations #7074

Merged
merged 1 commit into from Dec 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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