Skip to main content

A simple Django app to store and retrieve application settings in the database

Project description

django-settings2

A simple Django app to store and retrieve application settings in the database.

Requirements

  • Python >= 3.6
  • Django >= 3.2

Installation

pip install django-settings2

Configuration

Add to INSTALLED_APPS

INSTALLED_APPS = [
    ...
    "django_settings2",
]

Run migrations

python manage.py migrate

Usage

from django_settings2.models import DjangoSettings

# Store a value
DjangoSettings.set_value("my_key", "hello")
DjangoSettings.set_value("max_retries", 5, cls=int)
DjangoSettings.set_value("threshold", 0.75, cls=float)

# Retrieve a value
value = DjangoSettings.get_value("my_key", default="fallback")

# Retrieve a JSON value stored as text
data = DjangoSettings.get_value_json("my_json_key", default={})

# Retrieve with row-level lock (useful in transactions)
data = DjangoSettings.get_value_json("my_json_key", lock=True)

License

MIT

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_settings2-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_settings2-1.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file django_settings2-1.0.0.tar.gz.

File metadata

  • Download URL: django_settings2-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.17

File hashes

Hashes for django_settings2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 10ef98342f22ee66a5efb9adc4885a10d0193794705d912ea4c19d2610d3d2ff
MD5 06f6c6860864e903266f8bc8c8bda6b4
BLAKE2b-256 0df52259d965b793ddfe2a0aa2da1d35435c3caf456b9ab60ef57d25e628bb6b

See more details on using hashes here.

File details

Details for the file django_settings2-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_settings2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59bb746fd3c57d4fb1e3aaa10cc1b555a565c0067d0cb034621513887e6d9e69
MD5 41e6e6ea30b7429472f537d40188b044
BLAKE2b-256 c69679a670c3125464d7461b30d43b242a05f04422244b0d821a7274b7f9ff52

See more details on using hashes here.

Supported by

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