🛡️ django-env-check
Validate your environment variables before Django starts
A tiny, zero-dependency helper that ensures all required environment variables are present before your Django app starts.
🎯 Why django-env-check?
Every Django project relies on environment variables, but most developers never validate whether they exist. This leads to:
- ❌ Missing
SECRET_KEYorDATABASE_URL - ❌ Silent misconfigurations in production
- ❌ Email failures due to missing credentials
- ❌ API integration issues
- ❌ Hard-to-debug runtime errors
django-env-check solves this with one line of code. ✨
🚀 Installation
pip install django-env-check
📖 Usage
Basic 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 (Development)
In development, you may want warnings instead of hard failures:
check_env(["SECRET_KEY"], warn_only=True)
Output:
⚠️ WARNING: [django-env-check] Missing environment variables: SECRET_KEY
💡 Auto-enable Warning Mode in DEBUG
from django.conf import settings
check_env(
["SECRET_KEY", "DATABASE_URL"],
warn_only=settings.DEBUG
)
✨ Features
✅ Return Value
check_env(...) returns True when:
- All variables exist OR
warn_only=True(even if variables are missing)
Use this in custom logic:
if check_env(["API_KEY"], warn_only=True):
# Continue with setup
pass
❗ Custom Exception Handling
Missing variables raise EnvMissingError:
from env_check import check_env, EnvMissingError
try:
check_env(["SECRET_KEY"])
except EnvMissingError as e:
print(f"⚠️ Config error: {e}")
🧪 Testing Your Installation
Test warning mode:
python -c "from env_check import check_env; check_env(['X'], warn_only=True)"
Test error mode (should raise EnvMissingError):
python -c "from env_check import check_env; check_env(['X'])"
📁 Project Structure
django-env-check/
├── env_check/
│ ├── __init__.py
│ └── checker.py
├── pyproject.toml
├── README.md
└── LICENSE
🤝 Contributing
Contributions are welcome! 🎉
- 🐛 Found a bug? Open an issue
- 💡 Have a feature idea? Submit a pull request
- 📝 Improve documentation? PRs are appreciated!
📜 License
MIT License – Free to use, modify, and distribute.
⭐ Support the Project
If django-env-check helps you catch bugs early and ship safer code, please:
- ⭐ Star this repo on GitHub
- 🐦 Share it with your Django community
- 💬 Leave feedback or suggestions
Your support encourages new features & improvements! ❤️
Made with ❤️ for the Django community
Metadata
Release files for django-env-check 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django_env_check-0.1.2.tar.gz | 3.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_env_check-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / django_env_check-0.1.2.tar.gz
| Download URL | django_env_check-0.1.2.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
331d31b3cfa22b5532ef1697a09ff08540e3f8bfbb4b227394870c96a936d22a
|
|
BLAKE2b-256 checksum How to use checksums |
74ae4b926dbcf94c821fbb8e162bc5606e823e6694d1403cd9f1d1dea5042aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / django_env_check-0.1.2-py3-none-any.whl
| Download URL | django_env_check-0.1.2-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
406941f4328c92209c82aecf41c06b36738ef1aabfc56cce2ca0ddbc4cf4a723
|
|
BLAKE2b-256 checksum How to use checksums |
dd874cf72eec6f2924105bd839cb2a06834602f1dd580ba98f06f96600f1788a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for django-env-check 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.