Fix Django 3.0 deprecations (#7074)

This commit is contained in:
Ryan P Kilby 2019-12-04 14:14:43 -08:00 committed by GitHub
parent 4d9f9eb192
commit 95d4843abe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 9 deletions

View File

@ -23,7 +23,7 @@ from django.utils.dateparse import (
parse_date, parse_datetime, parse_duration, parse_time parse_date, parse_datetime, parse_duration, parse_time
) )
from django.utils.duration import duration_string 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.formats import localize_input, sanitize_separators
from django.utils.ipv6 import clean_ipv6_address from django.utils.ipv6 import clean_ipv6_address
from django.utils.timezone import utc from django.utils.timezone import utc
@ -1082,7 +1082,7 @@ class DecimalField(Field):
instance. instance.
""" """
data = smart_text(data).strip() data = smart_str(data).strip()
if self.localize: if self.localize:
data = sanitize_separators(data) data = sanitize_separators(data)

View File

@ -6,7 +6,7 @@ from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.db.models import Manager from django.db.models import Manager
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
from django.urls import NoReverseMatch, Resolver404, get_script_prefix, resolve 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 django.utils.translation import gettext_lazy as _
from rest_framework.fields import ( from rest_framework.fields import (
@ -452,7 +452,7 @@ class SlugRelatedField(RelatedField):
try: try:
return self.get_queryset().get(**{self.slug_field: data}) return self.get_queryset().get(**{self.slug_field: data})
except ObjectDoesNotExist: 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): except (TypeError, ValueError):
self.fail('invalid') self.fail('invalid')

View File

@ -6,7 +6,7 @@ See schemas.__init__.py for package overview.
import re import re
from weakref import WeakKeyDictionary 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.settings import api_settings
from rest_framework.utils import formatting from rest_framework.utils import formatting
@ -82,7 +82,7 @@ class ViewInspector:
method_docstring = getattr(view, method_name, None).__doc__ method_docstring = getattr(view, method_name, None).__doc__
if method_docstring: if method_docstring:
# An explicit docstring on the method or action. # 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: else:
return self._get_description_section(view, getattr(view, 'action', method.lower()), return self._get_description_section(view, getattr(view, 'action', method.lower()),
view.get_view_description()) view.get_view_description())

View File

@ -4,7 +4,7 @@ utils.py # Shared helper functions
See schemas.__init__.py for package overview. See schemas.__init__.py for package overview.
""" """
from django.db import models 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 from rest_framework.mixins import RetrieveModelMixin

View File

@ -7,7 +7,7 @@ from django.db import connection, models, transaction
from django.http import Http404 from django.http import Http404
from django.http.response import HttpResponseBase from django.http.response import HttpResponseBase
from django.utils.cache import cc_delim_re, patch_vary_headers 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.decorators.csrf import csrf_exempt
from django.views.generic import View from django.views.generic import View
@ -56,7 +56,7 @@ def get_view_description(view, html=False):
if description is None: if description is None:
description = view.__class__.__doc__ or '' description = view.__class__.__doc__ or ''
description = formatting.dedent(smart_text(description)) description = formatting.dedent(smart_str(description))
if html: if html:
return formatting.markup_description(description) return formatting.markup_description(description)
return description return description