Question

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

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top