Skip to main content

An ORM-based backend for Django Tasks

Project description

Django Tasks DB

CI PyPI PyPI - Python Version PyPI - Status PyPI - License

A Django Tasks backend which uses Django's ORM to store tasks in the database.

Installation

python -m pip install django-tasks

First, add django_tasks_db to your INSTALLED_APPS:

INSTALLED_APPS = [
    # ...
    "django_tasks_db",
]

Finally, add it to your TASKS configuration:

TASKS = {
    "default": {
        "BACKEND": "django_tasks_db.DatabaseBackend",
        "QUEUES": ["default"]
    }
}

Usage

Worker

You can run the db_worker command to run tasks as they're created. Check the --help for more options.

./manage.py db_worker

In DEBUG, the worker will automatically reload when code is changed (or by using --reload). This is not recommended in production environments as tasks may not be stopped cleanly.

Pruning old tasks

After a while, tasks may start to build up in your database. This can be managed using the prune_db_task_results management command, which deletes completed tasks according to the given retention policy. Check the --help for the available options.

Customizing the task id

By default, the database worker uses uuid.uuid4 to generate a task id. This can be customized using the id_function option:

TASKS = {
    "default": {
        "BACKEND": "django_tasks_db.DatabaseBackend",
        "OPTIONS": {
            "id_function": "uuid.uuid7"
        }
    }
}

The id_function must return a UUID (either uuid.UUID or string representation). Additionally, the PostgreSQL-specific RandomUUID or other database expressions are supported on Django 6.0+.

Contributing

See CONTRIBUTING.md for information on how to contribute.

Note: Prior to 0.12.0, this backend was included in django-tasks. Whilst the commit history was cleaned up, it's still quite messy. Don't look too closely.

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_tasks_db-0.12.0.tar.gz (26.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_tasks_db-0.12.0-py3-none-any.whl (28.8 kB view details)

Uploaded Python 3

File details

Details for the file django_tasks_db-0.12.0.tar.gz.

File metadata

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

File hashes

Hashes for django_tasks_db-0.12.0.tar.gz
Algorithm Hash digest
SHA256 314d486b8c1786705b4afaf03dadaf0b1b104163acce9c5d9c9bb2aef205c501
MD5 8a7f74a2d320686aa1e5c95e5ae58d9d
BLAKE2b-256 f425bc21ad4a610634f0a66f4faea4522eed26b55dbd50c4ac853128d24091d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_db-0.12.0.tar.gz:

Publisher: ci.yml on RealOrangeOne/django-tasks-db

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_tasks_db-0.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tasks_db-0.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69e3a1edcbf1efeeb1268da465e8ea5296ddd80834719769acc719b82da2d62e
MD5 2d259dd66069f129b7c9268ad3b5cc94
BLAKE2b-256 091ce14198615e22df28b333540f2e506d6ddef7aff16d510818e94ebc01440c

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_tasks_db-0.12.0-py3-none-any.whl:

Publisher: ci.yml on RealOrangeOne/django-tasks-db

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