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
- [Answered ]-Mixin to return a random object on each page load
- [Answered ]-Modify the raw url of Django request before all the normal processes
- [Answered ]-Django- Staticfiles 404 on runserver
Source:stackexchange.com