mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
str() -> six.text_type(). Closes #2290.
This commit is contained in:
parent
65fc0d0f77
commit
426547c61c
|
@ -5,8 +5,8 @@ In addition Django's built in 403 and 404 exceptions are handled.
|
|||
(`django.http.Http404` and `django.core.exceptions.PermissionDenied`)
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ungettext_lazy
|
||||
from rest_framework import status
|
||||
|
@ -66,7 +66,7 @@ class ValidationError(APIException):
|
|||
self.detail = _force_text_recursive(detail)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.detail)
|
||||
return six.text_type(self.detail)
|
||||
|
||||
|
||||
class ParseError(APIException):
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
from django.utils.encoding import smart_text
|
||||
from rest_framework.fields import get_attribute, empty, Field
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.utils import html
|
||||
# coding: utf-8
|
||||
from __future__ import unicode_literals
|
||||
from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured
|
||||
from django.core.urlresolvers import resolve, get_script_prefix, NoReverseMatch, Resolver404
|
||||
from django.db.models.query import QuerySet
|
||||
from django.utils import six
|
||||
from django.utils.encoding import smart_text
|
||||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from rest_framework.fields import get_attribute, empty, Field
|
||||
from rest_framework.reverse import reverse
|
||||
from rest_framework.utils import html
|
||||
|
||||
|
||||
class PKOnlyObject(object):
|
||||
|
@ -103,8 +105,8 @@ class RelatedField(Field):
|
|||
def choices(self):
|
||||
return dict([
|
||||
(
|
||||
str(self.to_representation(item)),
|
||||
str(item)
|
||||
six.text_type(self.to_representation(item)),
|
||||
six.text_type(item)
|
||||
)
|
||||
for item in self.queryset.all()
|
||||
])
|
||||
|
@ -364,8 +366,8 @@ class ManyRelatedField(Field):
|
|||
]
|
||||
return dict([
|
||||
(
|
||||
str(item_representation),
|
||||
str(item) + ' - ' + str(item_representation)
|
||||
six.text_type(item_representation),
|
||||
six.text_type(item) + ' - ' + six.text_type(item_representation)
|
||||
)
|
||||
for item, item_representation in items_and_representations
|
||||
])
|
||||
|
|
Loading…
Reference in New Issue
Block a user