Skip to main content

DJ-Registry

This is a simple, easy access key-value registry for Django. Sometimes you would like to have some flexibility in your settings. Putting your settings in settings.py or as environment variables also mean an engineer familiar with code or command line is required to alter them.

This Django app leverage the built-in Django admin so changing settings is easier as you can use the web interface.

Requirements

  • Python = "^3.6"
  • Django = "^3"

Run the following command inside project's root folder to install it's dependencies with Poetry:

$ poetry install

You can specify to the command that you do not want the development dependencies installed by passing the --no-dev option.

If you have not yet installed Poetry, please refer to their official documentation.

Installation

Install DJ-Registry with your favorite Python package manager:

(venv)$ pip install dj_registry

Add registry to your INSTALLED_APPS settings:

INSTALLED_APPS = [
    # other apps...

    'registry',
]

Migrate the database

(venv)$ ./manage.py migrate

Then, we're all set!

Usage

Log in to the admin, and create some keys under the Django Registry > Entries section. Let's say, we create mailgun.key and mailgun.domain with the corresponding string type and values. We then create another entry with game.max_score as the key, 10000 as the value and integer as the type.

The following example shows you how to access them in code:

from registry.helper import reg

key = reg['mailgun.key']            # the key that you set
domain = reg['mailgun.domain']      # the domain that you set

max_score = reg['game.max_score']   # 10000, it is returned as an int

You can also use get if you want to have a default and avoid exceptions if the key is not available (not enabled or does not exist)

reg.get('game.levels', 10)          # return 10 if key not found or disabled
reg['game.levels']                  # KeyError if key not found or disabled

You can set or delete entry if you want

reg['game.levels'] = 12             # Set game.levels to 12 (integer) and save
del reg['game.levels']              # Delete game.levels

Enabled and comment field

If you want to disable a key, just toggle the enabled boolean in the admin interface. It would be treated as if the key didn't exist. This is something meant to be used in the admin interface. If you want to manipulate this in the code, you will have to access the raw model like the following:

from registry.models import Entry

e = Entry.objects.get('game.levels')
e.enabled = False
e.save()

The comment field is also meant to be used in the admin interface. It is a convenient cell for user to put comments regarding to the settings, something like the following:

50: average use case.
9999: maximum special case

Types

integer, float, string, and boolean are the supported types for now.

Metadata

Release files for dj_registry 0.2.3

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_registry 0.2.3
File Size Uploaded Provenance Actions
dj_registry-0.2.3.tar.gz 5.0 kB Without provenance Details for dj_registry-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dj_registry 0.2.3
File Interpreter ABI Platform Actions
dj_registry-0.2.3-py3-none-any.whl Python 3 none any Details for dj_registry-0.2.3-py3-none-any.whl

Total release size: 12.3 kB

Release files / dj_registry-0.2.3.tar.gz

Download URL dj_registry-0.2.3.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4a97984738c8eea3fe3acc3b66f4defbd704eb4616f017bcaff2fc68cba347ed
BLAKE2b-256 checksum
How to use checksums
bc8f6a5430cbe6000780bebd1ba2a304eff5d1a70b68724a97207fc13afe81a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.2 Linux/6.5.0-1023-azure

Release files / dj_registry-0.2.3-py3-none-any.whl

Download URL dj_registry-0.2.3-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32ad4cf569f7f4b1d047d69feb9bc060082bd5a1b1dc95ca4302236637ebb6e5
BLAKE2b-256 checksum
How to use checksums
5d51c8f6c3c5e151ef44e60e986aba980154b6b00885348b7f154ecf03240f77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.2 Linux/6.5.0-1023-azure

Security for dj_registry 0.2.3

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