Need help with dynaconf?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Global Rank
#6,946
Topics of expertise
environ...
flask-e...
environ...
flask-r...
marshma...
cargo
vault
swagger...
Location
Viana do Castelo, Portugal
1.8K Stars 177 Forks MIT License 537 Commits 83 Opened issues

Description

Configuration Management for Python ⚙

Services available

!
?

Need anything else?

Contributors list

# 6,946
Flask
environ...
flask-r...
openapi
344 commits
# 65,306
environ...
HTML
Flask
Django
22 commits
# 47,936
mvc-fra...
Shell
environ...
Flask
9 commits
# 167,531
Git
python3
environ...
Flask
8 commits
# 112,513
Shell
GraphQL
twelve-...
Django
3 commits
# 289,536
environ...
Shell
HTML
Flask
3 commits
# 284,871
environ...
HTML
Flask
environ...
3 commits
# 290,586
environ...
Python
Shell
HTML
3 commits
# 288,073
HTML
Shell
environ...
Flask
3 commits
# 250,888
environ...
Flask
environ...
Django
3 commits
# 194,960
environ...
Shell
Flask
environ...
3 commits
# 326,985
environ...
Python
Shell
HTML
2 commits
# 183,558
environ...
Shell
Flask
environ...
2 commits
# 302,261
environ...
Shell
HTML
Flask
2 commits
# 243,751
environ...
Flask
environ...
sed
2 commits
# 134,816
travis-...
Discord
environ...
HTML
2 commits
# 65,125
HTML
Shell
Ansible
Django
2 commits
# 84,276
environ...
Shell
Flask
Django
2 commits
# 11,903
golang
Flask
Bootstr...
Neovim
2 commits
# 100,611
GraphQL
nexus
environ...
Flask
2 commits

Dynaconf

dynaconf - Configuration Management for Python.

MIT License PyPI PyPI PyPI - Downloads Build Status Azure DevOps builds (branch) Azure DevOps builds (branch) codecov Codacy Badge GitHub issues GitHub stars GitHub Release Date GitHub commits since latest release GitHub last commit Code Style Black Discussion Discussion

Foo

Features

  • Inspired by the 12-factor application guide
  • Settings management (default values, validation, parsing, templating)
  • Protection of sensitive information (passwords/tokens)
  • Multiple file formats
    toml|yaml|json|ini|py
    and also customizable loaders.
  • Full support for environment variables to override existing settings (dotenv support included).
  • Optional layered system for multi environments
    [default, development, testing, production]
  • Built-in support for Hashicorp Vault and Redis as settings and secrets storage.
  • Built-in extensions for Django and Flask web frameworks.
  • CLI for common operations such as
    init, list, write, validate, export
    .
  • full docs on https://dynaconf.com

Quick start

DEMO: You can see a working demo here: https://github.com/rochacbruno/learndynaconf

Install

$ pip install dynaconf

Initialize Dynaconf on project root directory

$ cd path/to/your/project/

$ dynaconf init -f toml

⚙️ Configuring your Dynaconf environment

🐍 The file config.py was generated.

🎛️ settings.toml created to hold your settings.

🔑 .secrets.toml created to hold your secrets.

🙈 the .secrets.* is also included in .gitignore beware to not push your secrets to a public repo.

🎉 Dynaconf is configured! read more on https://dynaconf.com

TIP: You can select

toml|yaml|json|ini|py
on
dynaconf init -f 
toml is the default and also the most recommended format for configuration.

Dynaconf init creates the following files

.
├── config.py       # This is from where you import your settings object (required)
├── .secrets.toml   # This is to hold sensitive data like passwords and tokens (optional)
└── settings.toml   # This is to hold your application setttings (optional)

On the file

config.py
Dynaconf init generates the following boilerpate
from dynaconf import Dynaconf

settings = Dynaconf( envvar_prefix="DYNACONF", # export envvars with export DYNACONF_FOO=bar. settings_files=['settings.yaml', '.secrets.yaml'], # Load files in the given order. )

TIP: You can create the files yourself instead of using the

init
command as shown above and you can give any name you want instead of the default
config.py
(the file must be in your importable python path) - See more options that you can pass to
Dynaconf
class initializer on https://dynaconf.com

Using Dynaconf

Put your settings on

settings.{toml|yaml|ini|json|py}
username = "admin"
port = 5555
database = {name='mydb', schema='main'}

Put sensitive information on

.secrets.{toml|yaml|ini|json|py}
password = "secret123"

IMPORTANT:

dynaconf init
command puts the
.secrets.*
in your
.gitignore
to avoid it to be exposed on public repos but it is your responsibility to keep it safe in your local environment, also the recommendation for production environments is to use the built-in support for Hashicorp Vault service for password and tokens.

Optionally you can now use environment variables to override values per execution or per environment.

# override `port` from settings.toml file and automatically casts as `int` value.
export DYNACONF_PORT=9900

On your code import the

settings
object
from path.to.project.config import settings

Reading the settings

settings.username == "admin" # dot notation with multi nesting support settings.PORT == 9900 # case insensitive settings['password'] == "secret123" # dict like access settings.get("nonexisting", "default value") # Default values just like a dict settings.databases.name == "mydb" # Nested key traversing settings['databases.schema'] == "main" # Nested key traversing

More

  • Settings Schema Validation
  • Custom Settings Loaders
  • Vault Services
  • Template substitutions
  • etc...

There is a lot more you can do, read the docs: http://dynaconf.com

Contribute

Main discussions happens on t.me/dynaconf learn more about how to get involved on CONTRIBUTING.md guide

more

If you are looking for something similar to Dynaconf to use in your Rust projects: https://github.com/rubik/hydroconf

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.