diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/base.py | 5 |
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__ |
