summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-11-27 09:45:37 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-11-27 09:45:37 +0100
commit2ea80b94d7f6e0d25207d6b716c52ca4c57a02fb (patch)
tree02c7c97425b7967fedac38ce337124af50993419 /django
parent29d59a879ea5b116cc31a2fd91be1f7562e487c2 (diff)
Fixed #19362 -- Detected invalid use of @python_2_unicode_compatible.
Thanks m3wolf for the report and akaariai for reproducing the problem.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index a1f9e2f26e..bf9854d289 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -416,6 +416,11 @@ class Model(six.with_metaclass(ModelBase, object)):
def __str__(self):
if not six.PY3 and hasattr(self, '__unicode__'):
+ if type(self).__unicode__ == Model.__str__:
+ klass_name = type(self).__name__
+ raise RuntimeError("%s.__unicode__ is aliased to __str__. Did"
+ " you apply @python_2_unicode_compatible"
+ " without defining __str__?" % klass_name)
return force_text(self).encode('utf-8')
return '%s object' % self.__class__.__name__