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/validators.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/validators.py')
| -rw-r--r-- | rest_framework/validators.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/rest_framework/validators.py b/rest_framework/validators.py index 63eb7b22..e3719b8d 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -6,7 +6,9 @@ This gives us better separation of concerns, allows us to use single-step object creation, and makes it possible to switch between using the implicit `ModelSerializer` class and an equivalent explicit `Serializer` class. """ +from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ +from rest_framework.compat import unicode_to_repr from rest_framework.exceptions import ValidationError from rest_framework.utils.representation import smart_repr @@ -59,10 +61,10 @@ class UniqueValidator: raise ValidationError(self.message) def __repr__(self): - return '<%s(queryset=%s)>' % ( + return unicode_to_repr('<%s(queryset=%s)>' % ( self.__class__.__name__, smart_repr(self.queryset) - ) + )) class UniqueTogetherValidator: @@ -141,11 +143,11 @@ class UniqueTogetherValidator: raise ValidationError(self.message.format(field_names=field_names)) def __repr__(self): - return '<%s(queryset=%s, fields=%s)>' % ( + return unicode_to_repr('<%s(queryset=%s, fields=%s)>' % ( self.__class__.__name__, smart_repr(self.queryset), smart_repr(self.fields) - ) + )) class BaseUniqueForValidator: @@ -205,12 +207,12 @@ class BaseUniqueForValidator: raise ValidationError({self.field: message}) def __repr__(self): - return '<%s(queryset=%s, field=%s, date_field=%s)>' % ( + return unicode_to_repr('<%s(queryset=%s, field=%s, date_field=%s)>' % ( self.__class__.__name__, smart_repr(self.queryset), smart_repr(self.field), smart_repr(self.date_field) - ) + )) class UniqueForDateValidator(BaseUniqueForValidator): |
