Skip to main content

Djheroku

Djheroku is a helper script that reads Heroku configuration from environment variables and injects them to Django configuration.

Build Status Test Coverage Requirements Status Latest Version Wheel Status License

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.

Release files for Djheroku 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Djheroku 0.6.1
File Size Uploaded
Djheroku-0.6.1.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Djheroku 0.6.1
File Interpreter ABI Platform
Djheroku-0.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 43.6 kB

Release files / Djheroku-0.6.1.tar.gz

Download URL Djheroku-0.6.1.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6c47be5b384472f9340c10bea162587dc7bb7d2af235d055d4959fb47a9c427d
BLAKE2b-256 checksum
How to use checksums
f05c53d883b80278d4e0280f2f18d165ae24359278d245da7f4b4bc6c6814971
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / Djheroku-0.6.1-py3-none-any.whl

Download URL Djheroku-0.6.1-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
804f2c60f393312c4a597d12203a021b40761300af22caa5186efe2085501184
BLAKE2b-256 checksum
How to use checksums
71b869b529df1d16f501440639d834d38eb5492eadc87043cc274e89ed31dbb1
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

3 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.1

1 release file

0.5.0

1 release file

0.4.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page