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 docs to explain env_prefix does not apply to field alias #147

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Changes from 1 commit
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
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_')

auth_key: str = Field('xxx', alias='AuthKey') # (1)!
hramezani marked this conversation as resolved.
Show resolved Hide resolved
```

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

### Case-sensitivity

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