Domanda

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

È stato utile?

Soluzione

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

Altri suggerimenti

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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top