Why does Field(exclude=True) make the attribute completely inaccessible? #9978
-
|
I have a model that I want to store some attributes in that I don't want exposed when the model is returned as an API Response in FastAPI. If I set Here is an example: @router.get(
"/profile/",
response_model=SessionData,
response_model_exclude={"key_id", "key_ttl"},
response_model_exclude_none=True,
name="profile",
status_code=status.HTTP_200_OK
)
async def get_profile(state_data: dict = Depends(user_session((validator, [CT.SESSION])))):
"""
User must be logged-in to see their profile
"""
session_data = state_data.get('SessionData')
return session_dataHere is the error that I'm seeing: As soon as I remove I don't want to make this attribute to completely disappear - I just don't want it dumped/serialized anywhere. What am I missing here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Apologies - I see the problem now in my code. Please disregard. |
Beta Was this translation helpful? Give feedback.
Apologies - I see the problem now in my code. Please disregard.