summaryrefslogtreecommitdiff
path: root/django/db/models/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models/base.py')
-rw-r--r--django/db/models/base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index f94d25c9f5..bf6588d7fe 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -266,7 +266,11 @@ class Model(object):
signals.post_init.send(sender=self.__class__, instance=self)
def __repr__(self):
- return smart_str(u'<%s: %s>' % (self.__class__.__name__, unicode(self)))
+ try:
+ u = unicode(self)
+ except (UnicodeEncodeError, UnicodeDecodeError):
+ u = '[Bad Unicode data]'
+ return smart_str(u'<%s: %s>' % (self.__class__.__name__, u))
def __str__(self):
if hasattr(self, '__unicode__'):