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"],
mapping_keys={
"ENV_KEY1": "DJANGO_KEY1",
"ENV_KEY2": "DJANGO_KEY2",
}
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也能实现相同效果,并且优先级更高。
- 如
mapping_keys用于处理环境变量名与django配置项名不一致的情况。- 如:把环境变量
ENV_KEY1的值加载为django的DJANGO_KEY1配置项。
- 如:把环境变量
- 环境变量值使用YAML格式编写。
版本
v0.1.0
- 版本首发,基本功能完成。
v0.1.1
- 添加:内外部KEY值映射的支持。
- 修正:打包后*.whl中没有包含有效代码的问题。
- 修正:加载配置项时没有移除前缀的问题。
v0.1.2
- 修正:需要忽略DJANGO_SETTINGS_MODULE配置项的问题。
Metadata
Release files for django-environ-settings 0.1.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 | Actions |
|---|---|---|---|---|
| django_environ_settings-0.1.2.tar.gz | 7.4 kB | Without provenance | Details for django_environ_settings-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_environ_settings-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for django_environ_settings-0.1.2-py3-none-any.whl |
Total release size: 14.6 kB
Release files / django_environ_settings-0.1.2.tar.gz
| Download URL | django_environ_settings-0.1.2.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85b59c93cfb4cedaca750d9845367b12082cea3719df36f2c230e1f6dc9799d2
|
|
BLAKE2b-256 checksum How to use checksums |
edb9243e47ec87f711da81fff1052a9de34eaef098eb7c3acd584dfad76c7008
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Release files / django_environ_settings-0.1.2-py3-none-any.whl
| Download URL | django_environ_settings-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fc5da2ea5d1b635e8016b6d06b96cc9635882b98d96d8f72f85dde0bed1f4f5
|
|
BLAKE2b-256 checksum How to use checksums |
99ae94ddc2224b6d004f3e6b04b05d7ed9894317201ceb2a3dc3b37aa30372e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.9
|
Security for django-environ-settings 0.1.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.