twoscoops / two-scoops-of-django-1.6

Tracking thoughts and feature requests for Two Scoops of Django 1.6
51 stars 7 forks source link

Use of python_2_unicode_compatible on method #61

Closed kevcampb closed 9 years ago

kevcampb commented 10 years ago

On page 207 on the first edition there is code

@python_2_unicode_compatible
def __str__(self):
    return self.name

This should be applied to the class, rather than to the str method, otherwise, you will get the error:

ValueError: @python_2_unicode_compatible cannot be applied to __str__ because it doesn't define __str__().