Skip to main content

Yet Another Django Settings Helper

This library allows secret settings to be easily changed for dev/Staging/Production etc purposes. e.g. One might obtain development settings from the process environment but later deploy to Google Compute Engine where use of Google Secret Manager is recommended. If the app later finds its way onto AWS, a suitable fetcher can be installed or written.

I tend to put all the secret settings for an environment in a single secret as a JSON document, for cost and convenience. You can also put non-secret settings in the same document or install them as environment variables as you prefer.

** I have no affiliation with Google, Amazon or any other cloud computing provider! **

Installation

pip install dj_secret_settings

Configuration

Install settings fetchers to get the raw data from the store, and settings stores to make sense of the raw data and return pieces of it on demand.

The package can be configured with a string or by using the environment variable DJ_SECRET_SETTINGS_URL with the form:

store_type+fetcher_type://information.used.by/the/fetcher/and/or/the/store_type?like_a=url

e.g. json+gsm://anything-here-perhaps-service-account/projects/123456789/secrets/my-secret/versions/42 indicates that data will be fetched from Google Secret Manager* and interpreted as a JSON string.

* configuration of this is obviously required too, contact me if you need help with that.

The package includes a Google Secret Manager fetcher, with JSON and environment variable store types. These can be overridden by installing a root package of the form dj_secret_settings_{store_type} (e.g. dj_secret_settings_json) or dj_secret_settings_{fetcher_type} (e.g dj_secret_settings_gsm). Alternatively you can install differently named root packages and modifiy the URL (e.g dj_secret_settings_yaml for a yaml store using the URL of the form yaml+gsm://...).

Usage

from dj_secret_settings import settings_store
store = settings.store.load("json+gsm://anything-here-perhaps-service-account/projects/123456789/secrets/my-secret/versions/42")

MAX_SIZE = store.get_value('MAX_SIZE', default=314, coerce_type=int)
IS_PRODUCTION = store.get_boolean('is_production', default=FALSE)
MY_LIST = store.get_array('MY_LIST')
A_MAP = store.get_mapping('A_MAP', default={})

defaults are always optional, as is coerce_type on get_value

Metadata

Release files for dj-secret-settings 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-secret-settings 0.1.1
File Size Uploaded Provenance Actions
dj_secret_settings-0.1.1.tar.gz 5.3 kB Without provenance Details for dj_secret_settings-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dj-secret-settings 0.1.1
File Interpreter ABI Platform Actions
dj_secret_settings-0.1.1-py3-none-any.whl Python 3 none any Details for dj_secret_settings-0.1.1-py3-none-any.whl

Total release size: 12.2 kB

Release files / dj_secret_settings-0.1.1.tar.gz

Download URL dj_secret_settings-0.1.1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ab3220edc72921c95363153a1dc2632ac36da0b4547d460735d232d5765843f2
BLAKE2b-256 checksum
How to use checksums
f43a1af0ca3851ede1cb86592d5b7ea5f704e79206c6624684f203a871f2607a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.8.6 Darwin/19.6.0

Release files / dj_secret_settings-0.1.1-py3-none-any.whl

Download URL dj_secret_settings-0.1.1-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7f24bf5b2f8e4df969676de086a00a62f860327f44f9738e045ccf8df772feb7
BLAKE2b-256 checksum
How to use checksums
e9efb03b477f0cfb87f79f8ed8477b59f5b49042ea51345573277784f6623b62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.7 CPython/3.8.6 Darwin/19.6.0

Security for dj-secret-settings 0.1.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page