Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
.. image:: https://badge.fury.io/py/django-getenv.svg :target: https://pypi.python.org/pypi/django-getenv
.. image:: https://travis-ci.org/schwuk/django-getenv.png?branch=master :target: https://travis-ci.org/schwuk/django-getenv
.. image:: https://landscape.io/github/schwuk/django-getenv/master/landscape.png :target: https://landscape.io/github/schwuk/django-getenv/master :alt: Code Health
A quick'n'easy way to use environment variables in your Django (and Python) projects.
If you're using
django-dotenv <https://github.com/jacobian/django-dotenv>
__ to get the
most out of your .env
file, you want to use the values there in your
Django <https://www.djangoproject.com/>
__ 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.
::
pip install django-getenv
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 <https://github.com/jacobian/django-dotenv>
__ and
dj-database-url <https://github.com/kennethreitz/dj-database-url>
__.
1.3.2 (2017-04-15) ++++++++++++++++++
1.3.1 (2014-03-07) ++++++++++++++++++
1.3.0 (2014-03-06) ++++++++++++++++++
1.2.0 (2014-01-14) ++++++++++++++++++
1.1.0 (2013-07-24) ++++++++++++++++++
1.0.0 (2013-07-19) ++++++++++++++++++
FAQs
Read settings from environment variables.
We found that django-getenv demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.