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/validators.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'rest_framework/validators.py') 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): -- cgit v1.2.3