mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
[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.
This commit is contained in:
@@ -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__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user