[Fixed]-Show fields in get all django panel

1👍

Inside your Auto model you must define a __str__ (for python 3) or __unicode__ (for python 2) method. Like this:

class Autor(models.Model):
    name = models.CharField(max_length=50)
    # other fields here

    def __str__(self):  # python 3
        return self.name

    def __unicode__(self):  # python 2
        return self.name
👤nik_m

0👍

Define a __unicode__() method if you’re on python 2 or __str__() if you’re on python 3, for your model.

0👍

Write the unicode() method in Author model(or str() if you’re using Python3),

class Author(models.Model):
    # Here fields stuff

    def __unicode__(self):
        return self.nomber  

class AutorAdmin(admin.ModelAdmin):
    model = Author
     fields = ('name', 'dob', 'hp')
    list_display = ['name','dob', 'hp']

edit : – if you want to return multiple values then try this

def __unicode__(self):
    return '%s %s %s' % (self.name, self.dob, self.hp)    

Leave a comment