문제

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top