Skip to main content

dj_settings: Project Settings the UNIX Way

build lint tests license codecov readthedocs pypi downloads build automation: yam Lint: ruff

dj_settings provides a robust, UNIX-inspired approach to managing application configuration. It reads settings from multiple locations with a clear priority order, supporting environment variables, .d directory overrides, and multiple configuration formats.

Originally designed for Django projects, it has evolved into a versatile configuration management solution suitable for any Python application.

Key Features

  • UNIX-style configuration hierarchy: Read from /etc/, ~/.config/, project directory, and environment variables
  • .d directory overrides: Override configuration files with drop-in directories (e.g., config.yml.d/*.yml)
  • Multiple format support: YAML, TOML, JSON, INI, and environment files
  • Type-safe settings classes: Create typed configuration objects with decorators
  • Environment variable integration: Seamlessly blend file-based and environment-based configuration
  • Array merging: Optionally merge arrays instead of overwriting them

Quick Start

from dj_settings import ConfigParser

parser = ConfigParser("/path/to/project/config.yml")

# Get a setting with the full fallback chain
database_url = parser.get_setting(
    "url",
    sections=["database"],
    default="sqlite:///db.sqlite3",
)

Or use type-safe settings classes:

from dj_settings import config_value, settings_class


@settings_class("/path/to/project/config.yml", merge_arrays=True)
class Settings:
    debug: bool = config_value("DEBUG", default=False)
    database_url: str = config_value("url", sections=["database"])
    allowed_hosts: list[str] = config_value(
        "allowed_hosts", sections=["server"], default=["localhost"]
    )


settings = Settings()
print(settings.debug)  # Type-safe access

Documentation

Why dj_settings?

Managing configuration across different environments (development, staging, production) is challenging. dj_settings solves this by:

  1. Following UNIX conventions: Uses the well-understood pattern of system-wide (/etc/), user-specific (~/.config/), and project-local configuration
  2. Supporting overrides: The .d directory pattern allows incremental configuration without modifying base files
  3. Being format-agnostic: Works with YAML, TOML, JSON, INI, and environment variables
  4. Providing type safety: Modern Python type hints and dataclasses for better IDE support and error detection

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dj_settings-9.0.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_settings-9.0.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file dj_settings-9.0.0.tar.gz.

File metadata

  • Download URL: dj_settings-9.0.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dj_settings-9.0.0.tar.gz
Algorithm Hash digest
SHA256 c9fb9dc0c3c016378d776e66c25544bd2277dccb8a8f052c67a7787983afb6eb
MD5 82831b8871be1375407811766195fd79
BLAKE2b-256 0f31e4d240464d28a22209f3168ea4c80a08447a96f2c687dd1f94ed77bbdd90

See more details on using hashes here.

File details

Details for the file dj_settings-9.0.0-py3-none-any.whl.

File metadata

  • Download URL: dj_settings-9.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dj_settings-9.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d83f5b43a055a1f966c579dd19027237838c1fc506523b71d76952c88b5e2a15
MD5 2ebf8c6d258b017440c5248b77e04339
BLAKE2b-256 7e13427be578c831e03a17cd62340c8b1559990eeca5573a0f9371b02e6cfcb4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

9.0.0 This release

2 files

8.0.0

2 files

7.0.0

2 files

6.0.0

2 files

5.0.0

2 files

4.2.1

2 files

4.2.0

2 files

4.1.0

2 files

4.0.0

2 files

3.0.1

2 files

3.0.0

2 files

2.1.0

2 files

2.0.0

2 files

1.0.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page