Some helper functionality for binding Heroku configuration to Django
Project description
Djheroku is a helper script that reads Heroku configuration from environment variables and injects them to Django configuration.
Autopilot for Heroku settings
This is an easier way to control what Django does. Just add a few lines to your settings.py:
from djheroku import autopilot autopilot(vars())
Then you can make runtime changes to your application settings:
heroku addons:add sendgrid heroku config:set ADDONS=sendgrid heroku addons:add memcachier heroku config:set ADDONS=sendgrid,memcachier
Djheroku will change the variables accordingly.
Configuration helpers
Example:
# settings.py from djheroku import sendgrid vars().update(sendgrid())
This is equivalent of typing in:
# settings.py import os if 'SENDGRID_USERNAME' in os.environ and 'SENDGRID_PASSWORD' in os.environ: EMAIL_HOST = 'smtp.sendgrid.net' EMAIL_HOST_USER = os.environ['SENDGRID_USERNAME'] EMAIL_HOST_PASSWORD = os.environ['SENDGRID_PASSWORD'] EMAIL_PORT = 587 EMAIL_USE_TLS = True
If any of the variables are not present, the configuration will be left as it is. Currently there are two helpers: sendgrid() and mailgun().
Middleware
There are three middleware classes in Djheroku. They are used to redirect permanently from one URL to another.
NoWwwMiddleware removed www. from URLs of incoming requests. The opposite is built-in functionality of Django. Enable this Middleware and set NO_WWW = True in settings.py to activate.
PreferredDomainMiddleware redirects all domains directed to the application to a preferred one.
ForceSSLMiddleware redirects all non-SSL connections to a secure connection.
Each of these middlewares does one thing only and combined they will lead into three separate redirects or even a eternal loop if configured properly wrong.
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
File details
Details for the file Djheroku-0.6.1.tar.gz
.
File metadata
- Download URL: Djheroku-0.6.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c47be5b384472f9340c10bea162587dc7bb7d2af235d055d4959fb47a9c427d |
|
MD5 | 23e8e607b8cb4bb7f03a75487b1162de |
|
BLAKE2b-256 | f05c53d883b80278d4e0280f2f18d165ae24359278d245da7f4b4bc6c6814971 |
File details
Details for the file Djheroku-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: Djheroku-0.6.1-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.44.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 804f2c60f393312c4a597d12203a021b40761300af22caa5186efe2085501184 |
|
MD5 | 903356b7db9fb7714017177b018319e3 |
|
BLAKE2b-256 | 71b869b529df1d16f501440639d834d38eb5492eadc87043cc274e89ed31dbb1 |