Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note about nested model should inherit BaseModel #165

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading