Closed skhaz closed 3 months ago
Why don't you use the Account
model as sub type:
accounts: Account = Field(default=..., json_schema_extra=Account.model_json_schema())
Then you have access to settings.accounts.username
I did not know. This is very nice! Thank you!
I am using Pydantic and Pydantic Settings, and they have been working very well. However, I have a JSON field in my .env, and using the JSON field it loads correctly (see functional example below). However, I would like to type this JSON field that Pydantic loads. I do not want it to be generic; I want it to have two fields (username and password) in its object. Typing is precisely why I use Pydantic.
Is there any way to do this?
.env