aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2014-12-15 11:55:17 +0000
committerTom Christie2014-12-15 11:55:17 +0000
commit72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9 (patch)
tree9d2fe5ded957a5e1c6d86ac87aeafb4be3055ab2 /rest_framework/fields.py
parenta72f812d80a4000e86a5ad96001f3fbf43fe310a (diff)
downloaddjango-rest-framework-72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9.tar.bz2
Use unicode internally everywhere for 'repr'
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 205efd2f..1a4712d8 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ValidationError as DjangoValidationError
@@ -10,7 +11,8 @@ from django.utils.translation import ugettext_lazy as _
from rest_framework import ISO_8601
from rest_framework.compat import (
EmailValidator, MinValueValidator, MaxValueValidator,
- MinLengthValidator, MaxLengthValidator, URLValidator, OrderedDict
+ MinLengthValidator, MaxLengthValidator, URLValidator, OrderedDict,
+ unicode_repr, unicode_to_repr
)
from rest_framework.exceptions import ValidationError
from rest_framework.settings import api_settings
@@ -113,7 +115,9 @@ class CreateOnlyDefault:
return self.default
def __repr__(self):
- return '%s(%s)' % (self.__class__.__name__, repr(self.default))
+ return unicode_to_repr(
+ '%s(%s)' % (self.__class__.__name__, unicode_repr(self.default))
+ )
class CurrentUserDefault:
@@ -124,7 +128,7 @@ class CurrentUserDefault:
return self.user
def __repr__(self):
- return '%s()' % self.__class__.__name__
+ return unicode_to_repr('%s()' % self.__class__.__name__)
class SkipField(Exception):
@@ -453,7 +457,7 @@ class Field(object):
This allows us to create descriptive representations for serializer
instances that show all the declared fields on the serializer.
"""
- return representation.field_repr(self)
+ return unicode_to_repr(representation.field_repr(self))
# Boolean types...