Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested 'self' field in Serializer #63

Open
Thorleon opened this issue Feb 25, 2018 · 2 comments
Open

Nested 'self' field in Serializer #63

Thorleon opened this issue Feb 25, 2018 · 2 comments

Comments

@Thorleon
Copy link

Is that possible somehow to have nested serializers, which contain object of the same class?
For example:

class PersonSerializer(serpy.Serializer):
    name = serpy.Field()
    age = serpy.IntField()
    childrens = PersonSerializer(many=True)

This code of course is invalid, but it should visualize my problem.
Marshmallow have something like:
childrens = fields.Nested('self', many=True)
If it's not possible I may try to implement feature like this.

@ahankinson
Copy link
Contributor

@benhawes
Copy link

That's just nesting a /different/ class - the issue comes when you need to nest the exact class you're defining.
For standard serializers, there's https://github.com/heywbj/django-rest-framework-recursive
but it would be nice if there was a way to do this withing serpy.

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

No branches or pull requests

3 participants