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:
6
main.py
6
main.py
@@ -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 #######################################
|
||||
|
||||
Reference in New Issue
Block a user