summaryrefslogtreecommitdiff
path: root/django/db/models
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-07-20 14:48:51 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-07-22 09:29:54 +0200
commitbdca5ea345c548a82a80d198906818c9ccbef896 (patch)
tree5c3f5fe5ad2522175d67b96a1fce1ff1763ba125 /django/db/models
parent3cb2457f46b3e40ff6b6acffcb3fd44cbea091e5 (diff)
[py3] Replaced unicode/str by six.text_type/bytes.
Diffstat (limited to 'django/db/models')
-rw-r--r--django/db/models/base.py14
-rw-r--r--django/db/models/fields/files.py2
2 files changed, 8 insertions, 8 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 04ae4bc96d..8c448b2f39 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -375,7 +375,7 @@ class ModelWithoutMeta(object):
def __repr__(self):
try:
- u = unicode(self)
+ u = six.text_type(self)
except (UnicodeEncodeError, UnicodeDecodeError):
u = '[Bad Unicode data]'
return smart_str('<%s: %s>' % (self.__class__.__name__, u))
@@ -790,8 +790,8 @@ class ModelWithoutMeta(object):
def date_error_message(self, lookup_type, field, unique_for):
opts = self._meta
return _("%(field_name)s must be unique for %(date_field)s %(lookup)s.") % {
- 'field_name': unicode(capfirst(opts.get_field(field).verbose_name)),
- 'date_field': unicode(capfirst(opts.get_field(unique_for).verbose_name)),
+ 'field_name': six.text_type(capfirst(opts.get_field(field).verbose_name)),
+ 'date_field': six.text_type(capfirst(opts.get_field(unique_for).verbose_name)),
'lookup': lookup_type,
}
@@ -806,16 +806,16 @@ class ModelWithoutMeta(object):
field_label = capfirst(field.verbose_name)
# Insert the error into the error dict, very sneaky
return field.error_messages['unique'] % {
- 'model_name': unicode(model_name),
- 'field_label': unicode(field_label)
+ 'model_name': six.text_type(model_name),
+ 'field_label': six.text_type(field_label)
}
# unique_together
else:
field_labels = map(lambda f: capfirst(opts.get_field(f).verbose_name), unique_check)
field_labels = get_text_list(field_labels, _('and'))
return _("%(model_name)s with this %(field_label)s already exists.") % {
- 'model_name': unicode(model_name),
- 'field_label': unicode(field_labels)
+ 'model_name': six.text_type(model_name),
+ 'field_label': six.text_type(field_labels)
}
def full_clean(self, exclude=None):
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index d3f1327315..b51ef1d5d6 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -265,7 +265,7 @@ class FileField(Field):
# Need to convert File objects provided via a form to unicode for database insertion
if value is None:
return None
- return unicode(value)
+ return six.text_type(value)
def pre_save(self, model_instance, add):
"Returns field's value just before saving."