made genre use the schemas properly to return actual joined data, not just genre_id. Also made author/publisher/genre all use many=True, while that is nto true for publisher, it makes the jinja code consisten -- Might need to fix this one day if the writing to the database is somehow more automatic and needs it to be an actual one-to-many, not a many-to-many

This commit is contained in:
2020-11-08 15:46:59 +11:00
parent c4fe3422a3
commit a57d68ecfa
2 changed files with 21 additions and 17 deletions

View File

@@ -91,16 +91,14 @@ class Genre_LstSchema(ma.SQLAlchemyAutoSchema):
class BookSchema(ma.SQLAlchemyAutoSchema):
author = ma.Nested(AuthorSchema, many=True)
publisher = ma.Nested(PublisherSchema)
publisher = ma.Nested(PublisherSchema, many=True)
genre = ma.Nested(Genre_LstSchema, many=True)
class Meta:
model = Book
include_relationships = True
load_instance = True
### DDP: do I need many=True on Author as books have many authors? (or in BookSchema declaration above?)
author_schema = AuthorSchema(many=True)
publisher_schema = PublisherSchema()
genre_schema = Genre_LstSchema(many=True)
book_schema = BookSchema()
####################################### ROUTES #######################################