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:55:26 +0100
commit71e5ad248e104f68a0d755cd5f76e86631607be5 (patch)
tree452f34c84d2e89ee67f226e7c46fb9aa8fd59517 /django
parent7c91b67cfaf4669df55a715e62d891faea796f20 (diff)
[1.5.x] Fixed #19362 -- Detected invalid use of @python_2_unicode_compatible.
Thanks m3wolf for the report and akaariai for reproducing the problem. Backport of 2ea80b9.
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__