The answers mentioning __str__ and __unicode__ methods are correct. As stated in the 医生 however, since version 1.6 (I think), you can use the python_2_unicode_compatible decorator for both Python 2 and Python 3:
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
class MyClass(models.Model):
def __str__(self):
return "Instance of my class"
Since this question is 6 years old, a lot of things have changed. Let me make an update to it.With python3.6 and the latest version of Django (2.1.2) you should always use __str__() in new code. __unicode__() is an old story for python2.7 because in python3, str is unicode.