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
0👍
Define a __unicode__()
method if you’re on python 2 or __str__()
if you’re on python 3, for your model.
- How to overcome the following url issue?
- Display time stored in database in HTML (django)
- Django python How to insert a json containing several objects in postgresql
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)
- Django python How to insert a json containing several objects in postgresql
- Source toaster start failed with error start django although it is exists
Source:stackexchange.com