Skip to main content

从环境变量中加载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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_environ_settings-0.1.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

django_environ_settings-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file django_environ_settings-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django_environ_settings-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c048c8ac6a440281076a267f82c98c0a5ec7cbe7249e96c0771ae10033e66f1
MD5 30b61fa987b98976bc5f3acee0235d32
BLAKE2b-256 27ed0f6972da61e8c58ba91e17860878e2774dcbe5fd471b984d640d3739ef41

See more details on using hashes here.

File details

Details for the file django_environ_settings-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_environ_settings-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba4c8255cc946c5ca7596a58e397dfbbd1f0e2e0248a5676a897f569ea059ac8
MD5 9a52917f19bb442c4f8a8f6d5c7287c1
BLAKE2b-256 6358d4d8f7e4df0ce042bacadaa9dcadae56797b61d50ddfb67209cb60614fd0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page