Skip to content

Commit

Permalink
修正一个查看没有评论的文章时后端报错
Browse files Browse the repository at this point in the history
  • Loading branch information
FantWings committed Sep 1, 2021
1 parent f369a6b commit a503442
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions crud/archives.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ def queryComment(archId):
.all()
)
data = []
for result in comments:
data.append(
{
"id": result.id,
"nickname": result.user.username,
"avatar": result.user.avatar,
"comment": result.comment,
"time": toTimeStamp(result.create_time),
}
)
if comments:
for result in comments:
data.append(
{
"id": result.id,
"nickname": result.user.username,
"avatar": result.user.avatar,
"comment": result.comment,
"time": toTimeStamp(result.create_time),
}
)
return {"data": data}

0 comments on commit a503442

Please sign in to comment.