在中
BookSchema,您将希望
Nested
authors像以前一样添加一个字段(但已将其注释掉),但是您将要使用
many关键字arguments来指定它将是一个列表。
class BookSchema(ma.ModelSchema): # A list of author objects authors = ma.Nested(AuthorSchema, many=True) class meta: model = Book

在中
BookSchema,您将希望
Nested
authors像以前一样添加一个字段(但已将其注释掉),但是您将要使用
many关键字arguments来指定它将是一个列表。
class BookSchema(ma.ModelSchema): # A list of author objects authors = ma.Nested(AuthorSchema, many=True) class meta: model = Book