aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/validators.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/validators.py
parenta72f812d80a4000e86a5ad96001f3fbf43fe310a (diff)
downloaddjango-rest-framework-72e08a3e8b6427cb93f0f98b42724e31e5b3d8f9.tar.bz2
Use unicode internally everywhere for 'repr'
Diffstat (limited to 'rest_framework/validators.py')
-rw-r--r--rest_framework/validators.py14
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):