testdrivenio / fastapi-vue

Single Page App with FastAPI and Vue.js
MIT License
265 stars 103 forks source link

Notes class in Database models refers to an invalid attribute #1

Closed kmcquade closed 1 year ago

kmcquade commented 3 years ago

https://github.com/testdrivenio/fastapi-vue/blob/master/services/backend/src/database/models.py#L22

Currently: return f"{self.title}, {self.author_id} on {self.created_at}"

However, the attribute author_id does not exist.

Perhaps it should be this instead?

return f"{self.title}, {self.author}, {self.id} on {self.created_at}"

gdvalderrama commented 3 years ago

@kmcquade according to the tortoise docs, using {FK_name}_id should return the id of the related model.

So it's not an issue, {self.author_id} with return the id of the related author.