I am trying to nest a Schema inside another Schema like the following:
class RecipePaginationSchema(PaginationSchema):
data = fields.Nested(RecipeSchema, attribute = "items", many = True)
The result should look something like this:
{
"links": {
"first": "http://localhost:5000/users/name/recipes?per_page=2&visibility=all&page=1",
"last": "http://localhost:5000/users/name/recipes?per_page=2&visibility=all&page=2",
"next": "http://localhost:5000/users/name/recipes?per_page=2&visibility=all&page=2"
},
"page": 1,
"pages": 2,
"per_page": 2,
"total": 3,
"data": [
{
"id": 11,
...
}
}
However, when I tried to use another attribute instead of "items", I didn't get the "data" part in the JSON response. So, what exactly is this attribute thing referring to?
By the way, I'm following Packt's Python API Development Fundamentals book.