Replies: 1 comment
-
Sorry for noise. I mixed up the project. I'm still sleeping. :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone!
Working a lot with Pydantic models I got the idea that it would be nice to be able to conditionally exclude fields during serialization.
The need to exclude a field may depend on the value of the field or, for example, on the serialization context. In this case, the exclusion rules could be controlled from within the serializer handler.
Here's a simple toy example of what I mean:
Also when using the serialization context:
This ability to control field exclusion rules directly from the serializer would be a useful more flexible addition to the existing exclusion mechanisms in Pydantic:
Field(exclude=True)
,model_dump(exclude={})
.What do you thing?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions