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
Metadata
Release files for django-getenv 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-getenv-1.3.2.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_getenv-1.3.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / django-getenv-1.3.2.tar.gz
| Download URL | django-getenv-1.3.2.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cede44ed68570aefe91a32925b28f1d111c93023bb387c5adb36bbd42c0e5739
|
|
BLAKE2b-256 checksum How to use checksums |
56edb9ff9f2fcdd4c6ce09f1284880b92733dac35b939b9d8d70ff69a02cc359
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_getenv-1.3.2-py2.py3-none-any.whl
| Download URL | django_getenv-1.3.2-py2.py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
d292571cefb84904a25d163689fc8f451c3cd090be72c6b3dc60a9c44730baee
|
|
BLAKE2b-256 checksum How to use checksums |
1842457565f727efa4d57fb9bd85eff3fae61878d598a9c2045cf430b0960fc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-getenv 1.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.