aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/validators.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/validators.py')
-rw-r--r--rest_framework/validators.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/rest_framework/validators.py b/rest_framework/validators.py
index 7ca4e6a9..e3719b8d 100644
--- a/rest_framework/validators.py
+++ b/rest_framework/validators.py
@@ -4,9 +4,11 @@ the using Django's `.full_clean()`.
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 equivelent explicit `Serializer` class.
+`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):