Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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.

Release History

Release History

This version
History Node

0.5.5

History Node

0.5.4

History Node

0.5.3

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0-1-g580bd5d

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Djheroku-0.5.5-py2-none-any.whl (13.8 kB) Copy SHA256 Checksum SHA256 py2 Wheel Dec 18, 2014
Djheroku-0.5.5-py3-none-any.whl (13.8 kB) Copy SHA256 Checksum SHA256 py3 Wheel Feb 23, 2016
Djheroku-0.5.5.tar.gz (18.7 kB) Copy SHA256 Checksum SHA256 Source Dec 18, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting