admin

Django - Display “Model Object” in the admin page instead of Object title

女生的网名这么多〃 提交于 2020-07-03 07:06:06
问题 As displayed in the image it displays "Lecture Object" instead of the Lecture's title. As I've understood it, unicode should take care of this, but it doesn't seem to here. Here is my unicode method: def __unicode__(self): return self.title 回答1: To display a custom string as your Model's object representation, you should: In Python 2.x def __unicode__(self): return self.some_attr # What you want to show In Python 3.x def __str__(self): return self.some_attr # What you want to show 来源: https:/