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_EXPOSEare 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
- Add the context processor to your
settings.pyinside theTEMPLATESconfiguration:
# settings.py
TEMPLATES = [
{
# ...
"OPTIONS": {
"context_processors": [
# ...
# Add this line:
"django_settings_expose.settings_expose",
],
},
},
]
- 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_EXPOSEis missing fromsettings.py, it throws anUndefinedSettingErroron startup. - If a template attempts to access a variable that wasn't whitelisted (e.g.,
{{ settings.SECRET_KEY }}), it throws anUnexposedSettingError.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_settings_expose-0.1.0.tar.gz.
File metadata
- Download URL: django_settings_expose-0.1.0.tar.gz
- Upload date:
- Size: 5.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f55ade949c91275e8fc66ddbf25f4ab9006d729b4395397b52dbd569ff1a0d3d
|
|
| MD5 |
60813e744cd8bf6e4306be0824f69749
|
|
| BLAKE2b-256 |
6cd2d0c622d2a828f19c4fbc65ec8f29c1a2f7cde8bb931e4353c7c6b229170f
|
File details
Details for the file django_settings_expose-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_settings_expose-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.2 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b79a1233647b705a8148785435816579f9bf075af239c0e2ec0ae5d87418f99a
|
|
| MD5 |
4768cca818b83282f2c2d36036aa447c
|
|
| BLAKE2b-256 |
b2e727991d7fe9a541d4dca061c1bd036950867fde52f808bf3b90aaa65220e7
|