Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danieljdufour/djenv
:sparkles: Load Django Settings from Environmental Variables with One Magical Line of Code
https://github.com/danieljdufour/djenv
django django-settings docker env environment environment-variables python python3 settings
Last synced: 2 months ago
JSON representation
:sparkles: Load Django Settings from Environmental Variables with One Magical Line of Code
- Host: GitHub
- URL: https://github.com/danieljdufour/djenv
- Owner: DanielJDufour
- License: cc0-1.0
- Created: 2020-06-21T03:32:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-10-29T12:57:46.000Z (about 1 year ago)
- Last Synced: 2024-05-22T15:33:52.576Z (8 months ago)
- Topics: django, django-settings, docker, env, environment, environment-variables, python, python3, settings
- Language: Python
- Homepage:
- Size: 21.5 KB
- Stars: 28
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- -awesome-django - djenv - Load Django settings from environmental variables. (Third-Party Packages / Configuration)
README
# DjEnv: Django + Environment
Load Django Settings Directly from Environmental Variables# features
- modify django configuration without modifying source code
- prevent hard-coding of Django settings
- works great with Docker# install
### with pip
```bash
pip install djenv
```
### with pipenv
```bash
pipenv install djenv
```# basic usage
```python3
# inside settings.py# import settings from environment
from djenv.settings import *
```Prepend Settings with `DJANGO_` to import them. For example:
```bash
DJANGO_DEBUG=False python3 manage.py runserver
```
Will set DEBUG=False in the settings.py# advanced usage
You can also replace nested settings like DATABASES by setting a JSON
```bash
DJANGO_DATABASES='{ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": "db.sqlite3" } }' python3 manage.py runserver
```