A tiny helper to validate required environment variables for Django.
Project description
📦 django-env-check
A tiny, zero-dependency helper that ensures all required environment variables are present before your Django app starts.
Useful for:
catching missing .env keys early
avoiding silent misconfigurations in production
safer deployments
enforcing required environment setup
Simple, lightweight, and framework-friendly.
🚀 Installation pip install django-env-check
🧠 Why this package?
Every Django project uses environment variables. But most developers never validate whether the required ones exist.
This leads to:
missing SECRET_KEY
wrong DATABASE_URL
email failures
API tokens missing
difficult-to-debug production issues
django-env-check solves this with one line of code.
🔧 Usage
Add this at the top of your settings.py:
from env_check import check_env
check_env([ "SECRET_KEY", "DATABASE_URL", "EMAIL_HOST_USER", "EMAIL_HOST_PASSWORD" ])
If any variable is missing, Django will refuse to start:
[django-env-check] Missing environment variables: SECRET_KEY, DATABASE_URL
🟡 Warning Mode (recommended for development)
In dev mode you may not want hard failures.
check_env(["SECRET_KEY"], warn_only=True)
Output:
WARNING: [django-env-check] Missing environment variables: SECRET_KEY
💡 Tip: Auto-enable warning mode in DEBUG check_env(["SECRET_KEY", "DATABASE_URL"], warn_only=DEBUG)
✔ Return Value
check_env(...) returns True when:
all variables exist
or warn_only=True (even if missing)
You can use this inside custom logic if needed.
❗ Custom Exception
If not using warning mode, missing variables raise:
env_check.EnvMissingError
You can catch it manually:
from env_check import check_env, EnvMissingError
try: check_env(["SECRET_KEY"]) except EnvMissingError as e: print("Config error:", str(e))
📁 Folder Structure env_check/ checker.py init.py pyproject.toml README.md LICENSE
🧪 Testing your installation python -c "from env_check import check_env; check_env(['X'], warn_only=True)"
python -c "from env_check import check_env; check_env(['X'])"
(Second one should raise EnvMissingError.)
📜 License
MIT License. Feel free to use, modify and contribute.
🤝 Contributing
Pull requests are welcome! If you’d like to improve features (like returning missing keys or adding default fallbacks), feel free to open an issue.
⭐ Support the project
If this package helps you, give it a star on GitHub ❤️ Your support encourages new features & improvements.
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_env_check-0.1.1.tar.gz.
File metadata
- Download URL: django_env_check-0.1.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa0ee13daea4c17bc42f1831bab6f4c6e283fbfb7bfbf238f18fd79e2a103c57
|
|
| MD5 |
9688ea3b4939fc8c573aa1dc865c7b85
|
|
| BLAKE2b-256 |
cd219b16871a3e09b934f6ebb229e476e3d2cb45e52045227d345aefbad0634c
|
File details
Details for the file django_env_check-0.1.1-py3-none-any.whl.
File metadata
- Download URL: django_env_check-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3022ce4449e4a9cfceb6d4c9527363eb57d8dba8e7e7774e4d8bdd3325f21dcc
|
|
| MD5 |
f6828096e13e8d1754f4e9534f6d2b26
|
|
| BLAKE2b-256 |
db8d8f17e25bee536c9dacba5496eb8fa024189e9fef5926a332108236f6ead3
|