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 support of SubModel instead of SubSettings #11

Closed
jag-k opened this issue Sep 20, 2024 · 0 comments · Fixed by #21
Closed

Add support of SubModel instead of SubSettings #11

jag-k opened this issue Sep 20, 2024 · 0 comments · Fixed by #21
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jag-k
Copy link
Owner

jag-k commented Sep 20, 2024

Code:

from pydantic import BaseModel, Field

from pydantic_settings import BaseSettings, SettingsConfigDict


class SubModel(BaseModel):
    val: int = 0
    flag: bool = False


class Settings(BaseSettings):
    model_config = SettingsConfigDict(env_nested_delimiter='__')

    nested_model: SubModel = Field(default_factory=SubModel)

Now:

# Configuration

Here you can find all available configuration options using ENV variables.

## Settings

Settings.

| Name           | Type       | Default                  | Description | Example                  |
|----------------|------------|--------------------------|-------------|--------------------------|
| `NESTED_MODEL` | `SubModel` | `{"val":0,"flag":false}` |             | `{"val":0,"flag":false}` |

Want to:

# Configuration

Here you can find all available configuration options using ENV variables.

## Settings

Settings.

### SubModel

SubModel.

**Environment Prefix**: `NESTED_MODEL__`

| Name                 | Type      | Default | Description | Example |
|----------------------|-----------|---------|-------------|---------|
| `NESTED_MODEL__VAL`  | `integer` | `0`     |             | `0`     |
| `NESTED_MODEL__FLAG` | `boolean` | `false` |             | `false` |
@jag-k jag-k self-assigned this Sep 20, 2024
@jag-k jag-k added the bug Something isn't working label Sep 20, 2024
@jag-k jag-k added this to the v0.3.0 milestone Sep 20, 2024
@jag-k jag-k modified the milestones: v0.3.0, v0.4.0 Oct 24, 2024
@jag-k jag-k changed the title Add support of SubModule instead of SubSettings Add support of SubModel instead of SubSettings Nov 27, 2024
@jag-k jag-k closed this as completed in #21 Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant