Skip to main content

Read settings from environment variables.

Project description

https://badge.fury.io/py/django-getenv.svg https://travis-ci.org/schwuk/django-getenv.png?branch=master Code Health

A quick’n’easy way to use environment variables in your Django (and Python) projects.

  • Free software: BSD license

Introduction

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")

You can also use getenv in a template:

::

{% load getenv %}

Current path: {% getenv “PATH” %}

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

History

1.3.2 (2017-04-15)

  • Use custom ImproperlyConfigured instead of Django’s (#5)

1.3.1 (2014-03-07)

  • Fix HISTORY.rst

  • Remove Python 2.6 from Travis configuration

1.3.0 (2014-03-06)

  • Improved (cookiecutter-pypackage style) project layout

1.2.0 (2014-01-14)

  • Specify an environment variable as required, and raise ImproperlyConfigured exception if not present (#2)

1.1.0 (2013-07-24)

  • Marked as “5 - Production/Stable” instead of “4 - Beta”

  • Cleaned up README

  • Added CHANGES

1.0.0 (2013-07-19)

  • Initial release

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.3.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_getenv-1.3.2-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-getenv-1.3.2.tar.gz.

File metadata

  • Download URL: django-getenv-1.3.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-getenv-1.3.2.tar.gz
Algorithm Hash digest
SHA256 cede44ed68570aefe91a32925b28f1d111c93023bb387c5adb36bbd42c0e5739
MD5 82ac975d8e876a2327c08c6cb699e89b
BLAKE2b-256 56edb9ff9f2fcdd4c6ce09f1284880b92733dac35b939b9d8d70ff69a02cc359

See more details on using hashes here.

File details

Details for the file django_getenv-1.3.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_getenv-1.3.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d292571cefb84904a25d163689fc8f451c3cd090be72c6b3dc60a9c44730baee
MD5 f01ed4c04129081126b89a5a09928988
BLAKE2b-256 1842457565f727efa4d57fb9bd85eff3fae61878d598a9c2045cf430b0960fc3

See more details on using hashes here.

Supported by

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