Skip to content

Commit ff5e9bb

Browse files
committedMay 30, 2020
fix: instance of Model does not have attr __name__
1 parent 6a9661f commit ff5e9bb

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed
 

‎src/models.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def check_password(self, password):
5555
return check_password_hash(self.password_hash, password)
5656

5757
def __repr__(self):
58-
return '<{name} {id} {username} {email}>'.format(name=self.__name__, id=self.id, username=self.username,
59-
email=self.email)
58+
return '<UserAuth {id} {username} {email}>'.format(id=self.id, username=self.username, email=self.email)
6059

6160

6261
class UserInfo(BaseModel):
@@ -73,8 +72,7 @@ class UserInfo(BaseModel):
7372
intro = db.Column(db.String(128), server_default='')
7473

7574
def __repr__(self):
76-
return '<{name} {id} {username} {country}>'.format(name=self.__name__, id=self.id, username=self.username,
77-
country=self.country)
75+
return '<UserInfo {id} {username} {country}>'.format(id=self.id, username=self.username, country=self.country)
7876

7977

8078
class Article(BaseModel):
@@ -92,8 +90,7 @@ class Article(BaseModel):
9290
section = db.Column(db.String(64), server_default='')
9391

9492
def __repr__(self):
95-
return '<{name} {id} {username} {title}>'.format(name=self.__name__, id=self.id, username=self.username,
96-
title=self.title)
93+
return '<Article {id} {username} {title}>'.format(id=self.id, username=self.username, title=self.title)
9794

9895

9996
class ArticleTag(BaseModel):
@@ -108,8 +105,7 @@ class ArticleTag(BaseModel):
108105
title = db.Column(db.String(128), nullable=False, server_default='')
109106

110107
def __repr__(self):
111-
return '<{name} {id} {tag} {username}>'.format(name=self.__name__, id=self.id, tag=self.tag,
112-
username=self.username)
108+
return '<ArticleTag {id} {tag} {username}>'.format(id=self.id, tag=self.tag, username=self.username)
113109

114110

115111
class ArticleComment(BaseModel):
@@ -124,6 +120,4 @@ class ArticleComment(BaseModel):
124120
country_code = db.Column(db.String(8), server_default='')
125121

126122
def __repr__(self):
127-
return '<{name} {id} {username} {body}>'.format(name=self.__name__, id=self.id, username=self.username,
128-
body=self.body[:16])
129-
123+
return '<ArticleComment {id} {username} {body}>'.format(id=self.id, username=self.username, body=self.body[:16])

0 commit comments

Comments
 (0)
Please sign in to comment.