Skip to content

Commit

Permalink
Add note about nested model should inherit BaseModel (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored Sep 13, 2023
1 parent 4f794c7 commit 3205f81
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,11 @@ from pydantic import BaseModel
from pydantic_settings import BaseSettings, SettingsConfigDict


class DeepSubModel(BaseModel):
class DeepSubModel(BaseModel): # (1)!
v4: str


class SubModel(BaseModel):
class SubModel(BaseModel): # (2)!
v1: str
v2: bytes
v3: int
Expand All @@ -276,6 +276,12 @@ print(Settings().model_dump())
"""
```

1. Sub model has to inherit from `pydantic.BaseModel`, Otherwise `pydantic-settings` will initialize sub model,
collects values for sub model fields separately, and you may get unexpected results.

1. Sub model has to inherit from `pydantic.BaseModel`, Otherwise `pydantic-settings` will initialize sub model,
collects values for sub model fields separately, and you may get unexpected results.

`env_nested_delimiter` can be configured via the `model_config` as shown above, or via the
`_env_nested_delimiter` keyword argument on instantiation.

Expand Down

0 comments on commit 3205f81

Please sign in to comment.