从环境变量中加载Django配置项。
Project description
django-environ-settings
从环境变量中加载Django配置项。
安装
pip install django-environ-settings
使用方法
在pro/settings.py
结尾处添加以下代码:
from django_environ_settings import django_environ_settings_patch_all
django_environ_settings_patch_all(
keys=["CONFIG_ITEM_KEY"],
namespace="DJANGO_",
)
namespace="DJANGO_"
表示只有以DJANGO_
开头的环境变量才被django使用,并用于更新移除DJANGO_
前缀后对应的配置项。- 如
django
中的数据库配置项DATABASES
对应的环境变量为DJANGO_DATABASES
。
- 如
keys
用于加载不使用namespace
前缀的环境变量。允许为空。- 如
CONFIG_ITEM_KEY
表示在djaong.conf.settings
中添加了额外的CONFIG_ITEM_KEY
配置项。 - 当前使用
namespace
前缀的环境变量DJANGO_CONFIG_ITEM_KEY
也能实现相同效果,并且优先级更高。
- 如
- 环境变量值使用YAML格式编写。
版本
v0.1.0
- 版本首发,基本功能完成。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_environ_settings-0.1.0.tar.gz
.
File metadata
- Download URL: django_environ_settings-0.1.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c048c8ac6a440281076a267f82c98c0a5ec7cbe7249e96c0771ae10033e66f1 |
|
MD5 | 30b61fa987b98976bc5f3acee0235d32 |
|
BLAKE2b-256 | 27ed0f6972da61e8c58ba91e17860878e2774dcbe5fd471b984d640d3739ef41 |
File details
Details for the file django_environ_settings-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_environ_settings-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba4c8255cc946c5ca7596a58e397dfbbd1f0e2e0248a5676a897f569ea059ac8 |
|
MD5 | 9a52917f19bb442c4f8a8f6d5c7287c1 |
|
BLAKE2b-256 | 6358d4d8f7e4df0ce042bacadaa9dcadae56797b61d50ddfb67209cb60614fd0 |