[Answered ]-Django shell: Model-to-string with unicode fails / fails not

1👍

If you leave off the __unicode__() from the end of your print statement, you will find it still works correctly. That’s because that method is automatically invoked when you call print.

When you just type the name of the object in the interpreter, the method that is invoked is __repr__.

Note that Django’s model instances all use unicode internally, so actually your __unicode__ method could just be return self.name.

1👍

Geo.repr() is invoked, when you print, but not unicode
EDIT: http://docs.python.org/library/functions.html#repr
Also i am not sure why parser got out underlines in the method names

Leave a comment