You need to implement the unicode() method in the Article model class.
For example:
class Article(models.Model):
name = models.Charfield()
def __unicode__(self):
return self.name
题
I am creating a website using django, I have a table called articles, whenever I create any new record it is showing correctly in the database (Postgres) and in the details page of django admin, but in the listing it is being displayed as: Article object. Any Idea?
Thanks
解决方案
You need to implement the unicode() method in the Article model class.
For example:
class Article(models.Model):
name = models.Charfield()
def __unicode__(self):
return self.name
其他提示
Define a __unicode__
method for your model.
I figured it out. I forgot to add the below in my model:
def __unicode__(self):
return self.title