Skip to main content

App-Parameter is a very simple Django app to save application's parameter in the database.

Project description

Django-app-parameter

Python Django coverage version ruff pyright licence

Django-app-parameter lets you store application settings in the database and update them at runtime through Django admin - no deployment or restart needed. Perfect for things like site titles, email addresses, feature flags, or any configuration that business users should control.

⚠️ Migration from v2.x to v3.0

Version 3.0 introduces a simplified API. Type-specific methods have been replaced with unified get() and set():

# Before (v2.x)
value = param.int()
param.set_int(42)
title = Parameter.objects.str("BLOG_TITLE")

# After (v3.0)
value = param.get()
param.set(42)
param = Parameter.objects.get(slug="BLOG_TITLE")
title = param.get()

New feature: auto_cast parameter to convert string input to native type:

param.set("42", auto_cast=True)  # Converts "42" to int for INT parameters

See CHANGELOG.md for full details.

📚 Full Documentation

Quick Start

Installation

pip install django-app-parameter

For encryption support (optional):

pip install django-app-parameter[cryptography]

Requirements: Python 3.10+ • Django 4.2+

Compatibility Matrix

Python Django 4.2 LTS Django 5.2 LTS Django 6.0
3.10
3.11
3.12
3.13
3.14

Configuration

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    "django_app_parameter",
]
  1. Optional - make global parameters available in all templates:
TEMPLATES = [
    {
        ...
        "OPTIONS": {
            "context_processors": [
                ...
                "django_app_parameter.context_processors.add_global_parameter_context",
            ],
        },
    },
]
  1. Run migrations:
python manage.py migrate
  1. Access Django admin to create your first parameters!

Basic Usage

Reading Parameters

In Python code:

from django_app_parameter import app_parameter

# Read parameter value
title = app_parameter.BLOG_TITLE
email = app_parameter.CONTACT_EMAIL

In templates (for global parameters):

<title>{{ BLOG_TITLE }}</title>

Writing Parameters

# Update parameter value programmatically
app_parameter.BLOG_TITLE = "My New Title"

Parameter Names → Slugs

Parameters are accessed via auto-generated slugs:

"Blog Title"     → BLOG_TITLE
"sender e-mail"  → SENDER_E_MAIL
"##weird@Na_me"  → WEIRDNA_ME

Features

Supported Types

String • Integer • Float • Boolean • URL • Email • JSON List • JSON Dict • File Path • Duration • Percentage • DateTime • Date • Time

Bulk Import/Export

Load parameters from JSON:

python manage.py dap_load --file parameters.json

Export all parameters:

python manage.py dap_dump --file backup.json

Example JSON format:

[
    {"name": "Site Title", "value": "My Site", "is_global": true},
    {"name": "Max Upload Size", "value": "10485760", "value_type": "INT"}
]

Use --no-update to only create new parameters without overwriting existing ones (useful in deployment scripts).

Validation

Attach validators to parameters (min/max value, length, regex, choices, etc.) - configured through Django admin or custom validators.

Encryption

Enable encryption for sensitive parameters (requires cryptography extra). Manage encryption keys with the dap_rotate_key command.

History Tracking

Enable enable_history to track all value changes with timestamps - viewable in Django admin.


📖 Read the full documentation for detailed information on all features.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for development guidelines.

Requirements for contributions:

  • Format code with Ruff
  • Add type hints (validated with Pyright)
  • Maintain 100% test coverage

Links

License

CC0 1.0 Universal - Public Domain

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_app_parameter-3.2.0.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

django_app_parameter-3.2.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

Details for the file django_app_parameter-3.2.0.tar.gz.

File metadata

  • Download URL: django_app_parameter-3.2.0.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_app_parameter-3.2.0.tar.gz
Algorithm Hash digest
SHA256 a69b46b407bc9b5d40b11d804276ab3789970a040ae831152f4084ab346fe151
MD5 5885a799a3e3caafb8a30e8142f086bf
BLAKE2b-256 e99c6528ce27032d6d88e043fa8f74869dd00fec0d53a55cf38aa0ae637e491b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_app_parameter-3.2.0.tar.gz:

Publisher: publish.yml on Swannbm/django-app-parameter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_app_parameter-3.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_app_parameter-3.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c95c79f88eb46d84e75055daf378979c360f7e5b61089c51354edf1c58711df
MD5 603d1a64ba345f42989faeb30988e0f4
BLAKE2b-256 068d1c663fe70a095a661e2ff894dda05044e7ebc91bdc1dec7cb98fedbd0d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_app_parameter-3.2.0-py3-none-any.whl:

Publisher: publish.yml on Swannbm/django-app-parameter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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