{"id":1822,"library":"dynaconf","title":"Dynaconf","description":"Dynaconf is a dynamic configuration management library for Python projects, inspired by the 12-factor application guide. It supports multiple file formats (TOML, YAML, JSON, INI, Python), environment variables, Hashicorp Vault, and Redis for settings and secrets. It provides a flexible, layered system for multi-environment configurations and includes built-in extensions for Flask and Django. The library is actively maintained, with the current version being 3.2.13, and receives regular updates and bug fixes.","status":"active","version":"3.2.13","language":"en","source_language":"en","source_url":"https://github.com/dynaconf/dynaconf","tags":["configuration","settings","dynamic","environment variables","toml","yaml","json","ini","secrets","multi-environment","cli"],"install":[{"cmd":"pip install dynaconf","lang":"bash","label":"Basic Installation"},{"cmd":"pip install dynaconf[toml,yaml,redis,vault]","lang":"bash","label":"Installation with Optional Dependencies"}],"dependencies":[{"reason":"For Redis backend support.","package":"redis","optional":true},{"reason":"For Hashicorp Vault backend support (installed via [vault] extra).","package":"hvac","optional":true},{"reason":"For YAML file support (installed via [yaml] extra).","package":"ruamel.yaml","optional":true},{"reason":"For TOML file support (installed via [toml] extra).","package":"toml","optional":true},{"reason":"For INI file support (installed via [ini] extra).","package":"configobj","optional":true}],"imports":[{"note":"The global `settings` instance is deprecated in Dynaconf 3.x. Users are encouraged to create their own `Dynaconf` instance instead.","wrong":"from dynaconf import settings","symbol":"Dynaconf","correct":"from dynaconf import Dynaconf"}],"quickstart":{"code":"from dynaconf import Dynaconf\n\n# Create settings files (e.g., settings.toml and .secrets.toml)\n# settings.toml:\n# [default]\n# FOO = 'bar'\n# DATABASE_URL = 'sqlite:///mydb.sqlite'\n#\n# .secrets.toml:\n# [default]\n# API_KEY = 'secret-key-123'\n\nsettings = Dynaconf(\n    envvar_prefix=\"DYNACONF\",\n    settings_files=['settings.toml', '.secrets.toml'],\n    environments=True, # Enable layered environments\n    load_dotenv=True # Explicitly enable .env file loading (disabled by default in 3.x)\n)\n\n# Access settings\nprint(f\"Foo: {settings.FOO}\")\nprint(f\"Database URL: {settings.DATABASE_URL}\")\n\n# Access secret\n# For production, consider using environment variables or a secure vault.\n# Example: export DYNACONF_API_KEY=\"my_prod_api_key\"\napi_key = settings.get('API_KEY', os.environ.get('DYNACONF_API_KEY', 'default-api-key'))\nprint(f\"API Key: {api_key}\")\n\n# Switch environment (e.g., in a development environment)\n# export ENV_FOR_DYNACONF=development\n\n# Example of setting a value programmatically (not persisted to file)\nsettings.set('NEW_SETTING', 'a new value')\nprint(f\"New setting: {settings.NEW_SETTING}\")","lang":"python","description":"This quickstart demonstrates how to initialize Dynaconf, load settings from specified TOML files (including a secrets file), and access configuration values. It highlights the importance of explicitly enabling `load_dotenv` and `environments` in version 3.x and shows how to access values, including sensitive ones, with a fallback to environment variables for production readiness."},"warnings":[{"fix":"Replace `from dynaconf import settings` with `from dynaconf import Dynaconf; settings = Dynaconf(...)`. Make sure to pass your `settings_files` explicitly.","message":"The global `settings` object (`from dynaconf import settings`) is deprecated in version 3.x. You should now explicitly instantiate `Dynaconf()` to manage your settings.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"When initializing `Dynaconf`, provide a list of your configuration files: `settings = Dynaconf(settings_files=['settings.toml', '.secrets.toml'])`.","message":"Automatic loading of settings files (e.g., `settings.toml`, `.secrets.yaml`) is disabled by default in Dynaconf 3.x. Files must now be explicitly passed via the `settings_files` argument during `Dynaconf` instantiation.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"To enable `.env` file loading, set `load_dotenv=True` during `Dynaconf` instantiation: `settings = Dynaconf(..., load_dotenv=True)`.","message":"Loading of `.env` files is disabled by default in Dynaconf 3.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure your IDE's run/test configuration sets the working directory to the root of your project. Alternatively, explicitly specify `root_path` when initializing `Dynaconf`.","message":"Dynaconf's path resolution relies on the Current Working Directory (CWD). Running tests or applications from an IDE that changes the CWD (e.g., PyCharm setting CWD to `./tests`) can cause `OSError: Starting path not found` as Dynaconf may fail to locate settings files.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Do not install or use `dynaconf==3.2.8` or `dynaconf==3.2.9`. Upgrade to `3.2.10` or later.","message":"Versions 3.2.8 and 3.2.9 were yanked from PyPI, indicating potential issues or regressions. Users should avoid these specific versions.","severity":"breaking","affected_versions":"3.2.8, 3.2.9"},{"fix":"Upgrade to `dynaconf==3.2.13` or a later version to patch these vulnerabilities.","message":"Templating vulnerabilities (`@jinja` and `@format`) were fixed in version 3.2.13. Older versions using these features might be susceptible to security risks. [cite: latest release notes]","severity":"breaking","affected_versions":"<3.2.13"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}