diff options
| author | Tom Christie | 2014-12-15 12:04:46 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-12-15 12:04:46 +0000 |
| commit | af53e34dd5873f3373e9991c3825e70d92432e14 (patch) | |
| tree | f5503776ef204ff125f476116b11ca0801fd3b8e /rest_framework/fields.py | |
| parent | 1f6fd924fea05b9b7eb4bedf44dfdcb2f14c5cad (diff) | |
| parent | dc66cce16da6793efe4a4a4dcdd18db62c859abb (diff) | |
| download | django-rest-framework-af53e34dd5873f3373e9991c3825e70d92432e14.tar.bz2 | |
Merge pull request #2279 from tomchristie/fix-serializer-repr-unicode-bug
Use unicode internally everywhere for 'repr'.
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 21a1effd..f3e17b18 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): @@ -463,7 +467,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... |
