model_dump()
's exclude
keyword argument doesn't exclude keys named the same thing in nested models
#9393
Unanswered
SeaswimmerTheFsh
asked this question in
Question
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, I have four classes...
AuroraBaseModel
pydantic.BaseModel
AuroraGuildModel
AuroraBaseModel
to_json()
method to match.Moderation
AuroraGuildModel
changes
, is a list ofChange
sChange
AuroraBaseModel
Whenever I use my
to_json()
method on an instance ofModeration
, I get an error saying that it can't JSON serialize theRed
type. Alright, that's an easy enough fix - but it isn't, because I'm already excluding thebot
attribute from mymodel_dump()
invocation, so my conclusion is thatmodel_dump()
's exclusions don't effect nested models. Is there a workaround for this?Beta Was this translation helpful? Give feedback.
All reactions