Skip to content

Commit

Permalink
Add docs to explain env_prefix does not apply to field alias (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
hramezani authored Aug 22, 2023
1 parent e100905 commit 919a20b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,23 @@ There are two ways to do this:

Check the [`Field` aliases documentation](../fields#field-aliases) for more information about aliases.

`env_prefix` does not apply to fields with alias. It means the environment variable name is the same
as field alis:

```py
from pydantic import Field

from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
model_config = SettingsConfigDict(env_prefix='my_prefix_')

foo: str = Field('xxx', alias='FooAlias') # (1)!
```

1. `env_prefix` will be ignored and the value will be read from `FooAlias` environment variable.

### Case-sensitivity

By default, environment variable names are case-insensitive.
Expand Down

0 comments on commit 919a20b

Please sign in to comment.