Skip to main content

Read settings from environment variables.

Project description

https://travis-ci.org/schwuk/django-getenv.png?branch=master Latest PyPI version Number of PyPI downloads

If you’re using django-dotenv to get the most out of your .env file, you want to use the values there in your Django project’s settings.

It will convert boolean, integer and float values to their native Python types.

There’s nothing here that is Django specific, but I’m using it with Django so that’s what I’ve called it.

Installation

pip install django-getenv

Usage

In your settings.py file (or equivalent), add:

from getenv import env

Then to read in your environment variables, do this:

SECRET_KEY = env("SECRET_KEY")

If you want to provide a default (in case the environment variable isn’t set), try:

SECRET_KEY = env("SECRET_KEY", "a_secret_key")

For best results, mix with django-dotenv and dj-database-url.

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

django-getenv-1.2.tar.gz (3.5 kB view hashes)

Uploaded Source

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