Lines are handled differently in Python 3 vs 2.
In 2, __str__() returned bytes, and __unicode__() returned characters. In 3, __str__() now returns characters, since strings are now initially unicode, and __unicode__() does not exist. If you really need the old 2 behavior for __str__() , I believe that now it is __bytes__() .
Short answer, stick with __str__() if you are using Python 3 and understand that Django tutorials explicitly state that they are written for 2.x, so there will be differences.
source share