This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Override arbitrary Django settings via environment variables.

  • Free software: BSD license

Installation

pip install django-env-overrides

Documentation

django-env-overrides lets you quickly adjust an existing Django app to load arbitrary settings from environment variables.

Setup

Add these lines to the end of your setup.py file:

import django_env_overrides
django_env_overrides.apply_to(globals())

Any environment variable prefixed with DJANGO__ will now be imported to your settings.

Example

settings.py:

DEBUG = True
MEDIA_URL = '/media/'
DATABASES = {
    'default': {
        'ENGINE': 'sqlite3',
    }
}
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
            ]
        }
    }
]

import django_env_overrides
django_env_overrides.apply_to(globals())

Environment:

DJANGO__SECRET_KEY=secret
DJANGO__MEDIA_URL=/new_url/
DJANGO__bool__DEBUG=False
POSTGRES=postgres://uf07k1:wegauwhg@ec2-107-21-253-135.compute-1.amazonaws.com:5431/d8r82722
DJANGO__db__DATABASES__default=$POSTGRES
DJANGO__TEMPLATES__0__OPTIONS__context_processors__1='my.context.processor'

Result:

DEBUG = False
MEDIA_URL = '/new_url/'
SECRET_KEY = 'secret'
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'd8r82722',
        'HOST': 'ec2-107-21-253-135.compute-1.amazonaws.com',
        'USER': 'uf07k1',
        'PASSWORD': 'wegauwhg',
        'PORT': 5431,
    }
}
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'OPTIONS': {
            'context_processors': [
                'django.contrib.auth.context_processors.auth',
                'my.context.processor',
            ]
        }
    }
]

Format for environment variables

The general format for environment variable names is:

<prefix>__<typecast>__<path>__<to>__<target>__<setting>

<prefix> defaults to DJANGO. If you want to use another prefix, use django_env_overrides.apply_to(globals(), prefix="MYPREFIX").

<typecast> (optional) is any type known to the django-environ package.
Currently the supported types are str, bool, int, float, json, list, tuple, dict, url, path, db_url, cache_url, search_url, and email_url. See the django-environ package for usage.

<typecast> is optional and defaults to str.

<path>__<to>__<target>__<setting> specifies the setting or subsetting the value should be assigned to. Path elements are treated as array indexes if they are integers, and otherwise as dictionary keys.

Development

See CONTRIBUTING.rst

Changelog

0.1.0 (2016-07-21)

  • First release on PyPI.
Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_env_overrides-0.1.0-py2.py3-none-any.whl (5.7 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jul 25, 2016
django-env-overrides-0.1.0.tar.gz (10.0 kB) Copy SHA256 Checksum SHA256 Source Jul 25, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development 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