From 7fd62dd68b148764d961d9b27c00086f592440fc Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 28 Jul 2021 09:42:29 +0530 Subject: [PATCH] Use __str__ instead of __repr__ Django uses this to get the string representation of an object --- {gmba_django => app}/convert.py | 0 app/models.py | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) rename {gmba_django => app}/convert.py (100%) diff --git a/gmba_django/convert.py b/app/convert.py similarity index 100% rename from gmba_django/convert.py rename to app/convert.py diff --git a/app/models.py b/app/models.py index ddc99d9..0834f21 100644 --- a/app/models.py +++ b/app/models.py @@ -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}