Skip to main content

Fast, cached Django settings exporter to templates.

Project description

django-settings-expose

A modern, high-performance, and cached Django context processor that safely exposes specific settings to your templates.

This is a heavily optimized drop-in replacement for the unmaintained django-settings-export package. Unlike the original implementation, django-settings-expose caches your exposed settings in memory at server startup, introducing zero performance overhead on later template renders.

Features

  • Zero-overhead: Settings are read and cached once when the server boots.
  • 🔒 Secure: Only whitelisted settings in SETTINGS_EXPOSE are exposed.
  • 🛑 Fail-fast: Throws clear, descriptive errors during development if you typo a setting name or try to access an unexposed variable in a template.

Installation

Install the package directly from PyPI:

pip install django-settings-expose

Configuration

  1. Add the context processor to your settings.py inside the TEMPLATES configuration:
# settings.py

TEMPLATES = [
    {
        # ...
        "OPTIONS": {
            "context_processors": [
                # ...
                # Add this line:
                "django_settings_expose.settings_expose",
            ],
        },
    },
]
  1. Define the list of settings you want to expose to your templates using SETTINGS_EXPOSE:
# settings.py

API_VERSION = "v1.2.6"
COMPANY_NAME = "My Awesome Company"
SECRET_KEY = "super-secret"  # Keep this safe!

# Whitelist variables to be accessible in templates
SETTINGS_EXPOSE = [
    "API_VERSION",
    "COMPANY_NAME",
]

Usage in Templates

All exposed settings are made available via a globally accessible {{ settings }} dictionary variable:

<footer>
  <p>Copyright © 2026 {{ settings.COMPANY_NAME }}</p>
  <p>API Version: {{ settings.API_VERSION }}</p>
</footer>

Error Handling

To protect you from typos and silent bugs, the library will raise explicit exceptions:

  • If a variable listed in SETTINGS_EXPOSE is missing from settings.py, it throws an UndefinedSettingError on startup.
  • If a template attempts to access a variable that wasn't whitelisted (e.g., {{ settings.SECRET_KEY }}), it throws an UnexposedSettingError.

License & Acknowledgements

This project is licensed under the BSD 3-Clause License.

It is based on the original concept of django-settings-export by Jakub Roztocil <jakub@subtleapps.com> (Copyright © 2014). Modified and optimized by Vladimir Klimenko <v.klimenko.2137@gmail.com> (Copyright © 2026).

Project details


Download files

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

Source Distribution

django_settings_expose-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

django_settings_expose-0.1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file django_settings_expose-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for django_settings_expose-0.1.1.tar.gz
Algorithm Hash digest
SHA256 edcd5ea93f5ec00adc5ebb98f3bddde8743a1b69ddd79a7854aa17acae35f497
MD5 6986bc1c52d201bb6d86a58ff5e8cd7b
BLAKE2b-256 701d118db549885bcda66d1eb33a3e81891991c81f702973b4ff2e3f4a5178cb

See more details on using hashes here.

File details

Details for the file django_settings_expose-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for django_settings_expose-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8de755b4c764ba86f268570152f6d6466c52505b9b742e9d7ce376dad18bdafe
MD5 d10681e91ab1017011815d25444cb188
BLAKE2b-256 8856f8dff3e658fe419f6770e6c493e6636ab3d47ab95ed3116420d1dcc3a252

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page