Use __str__ instead of __repr__
Django uses this to get the string representation of an object
This commit is contained in:
parent
b51520df63
commit
7fd62dd68b
2 changed files with 6 additions and 6 deletions
|
@ -23,7 +23,7 @@ class Field(models.Model):
|
|||
class Meta:
|
||||
db_table = 'field'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
def __str__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
@ -45,7 +45,7 @@ class Method(models.Model):
|
|||
class Meta:
|
||||
db_table = 'method'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
def __str__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
@ -86,7 +86,7 @@ class Person(models.Model):
|
|||
def fullname(self):
|
||||
return " ".join([self.title, self.first_name, self.last_name])
|
||||
|
||||
def __repr__(self):
|
||||
def __str__(self):
|
||||
return self.fullname()
|
||||
|
||||
def dict(self):
|
||||
|
@ -112,7 +112,7 @@ class Range(models.Model):
|
|||
class Meta:
|
||||
db_table = 'range'
|
||||
|
||||
def __repr__(self):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def dict(self):
|
||||
|
@ -144,7 +144,7 @@ class Resource(models.Model):
|
|||
class Meta:
|
||||
db_table = 'resource'
|
||||
|
||||
def __repr__(self):
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
def dict(self):
|
||||
|
@ -199,7 +199,7 @@ class Taxon(models.Model):
|
|||
class Meta:
|
||||
db_table = 'taxon'
|
||||
|
||||
def __repr__(self): return self.name
|
||||
def __str__(self): return self.name
|
||||
|
||||
def dict(self):
|
||||
return {'id': self.id, 'name': self.name}
|
||||
|
|
Loading…
Reference in a new issue