Skip to main content

Simple helpers for setting up your Django settings file

Project description

Simple helpers for setting up your Django settings file

https://secure.travis-ci.org/tswicegood/dj-settings-helpers.png?branch=master

Usage

Inside your settings.py file, do the following:

from dj_settings_helpers import create_project_dir, get_env
project_dir = create_project_dir(__file__)

Now, you can use project_dir to generate paths relative to your settings.py file and get_env to load environment variables.

For example, you can use it to add your project_root/templates directory to your TEMPLATES_DIRS setting like this:

TEMPLATES_DIRS = (
    project_dir('templates'),
)

You can use the get_env variable to pull in environment variables with defaults that depend on the ENVIRONMENT variable. For example, you can set multiple default BROKER_HOST variables for Celery like this:

BROKER_HOST = get_env('BROKER_HOST', 'default.rabbitmq.example.com',
        dev='localhost', staging='staging.rabbitmq.example.com')

If your ENVIRONMENT variable is equal to dev, the localhost string is used; if set to staging, it is staging.rabbitmq.example.com, and all other environments use default.rabbitmq.example.com. All of these are overridden by the presence of an environment variable named BROKER_HOST.

Please see the inline documentation in dj_settings_helpers.py for full examples and usage.

Installation

pip install dj-settings-helpers

License

Copyright 2012 Travis Swicegood

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Project details


Download files

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

Source Distribution

dj-settings-helpers-1.0.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file dj-settings-helpers-1.0.0.tar.gz.

File metadata

File hashes

Hashes for dj-settings-helpers-1.0.0.tar.gz
Algorithm Hash digest
SHA256 66b07a512055afa2ce224865f60875ba7822b1b5e4126f17769329b41985104f
MD5 4b38aae5c434d80f3cd2453481cf1a1a
BLAKE2b-256 c782baef002e949378422a9eb75987a3b88fb7b4e23a24b66f1c3e01cacc33b2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page