From 72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Mon, 15 Dec 2014 11:55:17 +0000 Subject: Use unicode internally everywhere for 'repr' --- rest_framework/fields.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rest_framework/fields.py') 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... -- cgit v1.2.3