Skip to content
This repository has been archived by the owner on Feb 21, 2020. It is now read-only.

Exclude doesn't work recursively #12

Open
bee-keeper opened this issue Dec 22, 2015 · 5 comments
Open

Exclude doesn't work recursively #12

bee-keeper opened this issue Dec 22, 2015 · 5 comments

Comments

@bee-keeper
Copy link

Hello,

It seems that exclude has no effect on nested serialised objects. Is this intentional?

@bruth
Copy link
Owner

bruth commented Dec 23, 2015

Can you provide an example?

@bee-keeper
Copy link
Author

I have a Django model with a fk and m2m. Serialise works perfectly but when I run the following, the field is only excluded in the outer level and appears in all subsequent nestings. I haven't had too much time to look into this, perhaps using templates is the solution?

serialize(my_obj, exclude=['my_field'])

@bruth
Copy link
Owner

bruth commented Feb 23, 2016

@bee-keeper Sorry for the late response. For recursive objects or models that appear more than one in a graph, templates are very good for. Here is an example of how I define and reference them.

@bee-keeper
Copy link
Author

Ok i had assumed that templates would be a solution, I suppose it was more a comment on the default behaviour without using a template. Please feel free to close in that case.

@bruth
Copy link
Owner

bruth commented Feb 24, 2016

I suppose it was more a comment on the default behaviour without using a template.

Yes. That being said, #5 describes an approach to define defaults per model. Also I have #14 in the works that defines a Serializer class that would encapsulate options like these.

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