Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Nested schema for Many To Many relations #168

Open
JaroslavAtPixofarm opened this issue Feb 10, 2023 · 1 comment
Open

Nested schema for Many To Many relations #168

JaroslavAtPixofarm opened this issue Feb 10, 2023 · 1 comment

Comments

@JaroslavAtPixofarm
Copy link

Hello,

Not really sure if i am doing something wrong, but it seems like nested schema for many-to-many fields is not supported.
When i tried to just add,

many_to_many_field = fields.Nested(ManyToManyFieldSchema, many=True) it was failing bcs ManyToManyManager is not iterrable.

Managed to do it at the end, but i think its a bit hacky sollution
many_to_many_field = fields.Function(lambda obj: [ManyToManyFieldSchema().dump(many-to-many-instance) for many-to-many-instance in obj.many_to_many_field.all()])

Is there a better/correct way how to handle many to many fields serialization or its really not supported "out of the box"?

Thanks!

@marcovelarde
Copy link

I think #99 do what you want

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants