Skip to content
This repository was archived by the owner on Jun 6, 2024. It is now read-only.
This repository was archived by the owner on Jun 6, 2024. It is now read-only.

including list of nested when serializing #308

Description

@g-brizolier

I am using json:api with python with a class that looks like this:

class ChildrenResultSerializer(JSONAPISerializer):
  children = fields.List(fields.Nested(ChildSerializer), allow_none=True)

and the other one looks like this:

class ChildSerializer(JSONAPISerializer):
    toys = fields.Relationship(
        many=True,
        type_="toys",
        include_resource_linkage=True,
        schema=ToySerializer,
        allow_none=True,
    )

In the ChildrenResultSerializer.serialize function, I want to be able to see the toys data for each of the children. I'm using it like this:

ChildrenResultSerializer.serialize(results, include_data=("children.toys"))

but I get this error: ValueError: Can only include relationships. "children" is a "List"

what am I doing wrong? I would like to keep children as a list of nested if possible.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions