Registry / web-framework / django-tasks

django-tasks

JSON →
library0.12.0pypypi✓ verified 25d ago

A backport of Django's built-in Tasks framework, `django-tasks` provides a robust way to run asynchronous background tasks within Django applications. As of version 0.12.0, it focuses on mirroring the upstream `django.tasks` package, with backends like DB and RQ now available as separate packages. It maintains an active release cadence, frequently updating to support new Django and Python versions.

pip install django-tasks
INSTALL
IMPORT
SIG · DJANGO-TASKS
D
django-tasks
web-frameworkpythonv0.12.0
Install
3.6s avg
Import
1055ms
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 1.122s · 66.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.6s · import 0.988s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

task
from django_tasks import task
from tasks import task

This quickstart demonstrates how to define a task using the `@task` decorator and enqueue it for asynchronous execution using `.delay()`. It includes a minimal Django configuration for testing, assuming the `django-tasks-db` backend is used and installed.

import os from django.conf import settings # Minimal Django setup for demonstration if not settings.configured: settings.configure( INSTALLED_APPS=[ 'django.contrib.auth', 'django.contrib.contenttypes', 'tasks' # Ensure 'tasks' is in INSTALLED_APPS ], DATABASES={ 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', } }, TASKS_BACKEND='tasks_db.backends.DatabaseBackend', # Or 'tasks_rq.backends.RQBackend' USE_TZ=True ) # Ensure migrations are run for tasks_db if using it # In a real project, this would be part of `manage.py migrate` import django django.setup() # This part assumes django-tasks-db is installed for the example # and that tasks.backends is configured. # For a true quickstart, you'd run `python manage.py makemigrations tasks_db && python manage.py migrate` from tasks import task @task def greet_user(name): print(f"Hello, {name}!") return f"Greeting for {name} completed." # Enqueue the task for asynchronous execution result = greet_user.delay("World") print(f"Task enqueued with ID: {result.pk}") # To process the task (typically run by a worker process) # For local testing, you might manually run the task # from tasks import run_task # run_task(result.pk) # You can inspect the result object (needs refresh if worker is separate) # result.refresh_from_db() # print(f"Task status: {result.status}") # print(f"Task result: {result.result}")
Debug
Known issues
breakingIn version `0.12.0`, the Database and RQ backends were extracted into separate packages (`django-tasks-db` and `django-tasks-rq`). If you previously used these backends, `django-tasks` no longer includes them directly.
fix
Install the new packages (e.g., `pip install django-tasks-db django-tasks-rq`) and update your `TASKS_BACKEND` setting in `settings.py` to point to the new backend paths (e.g., `'tasks_db.backends.DatabaseBackend'` or `'tasks_rq.backends.RQBackend'`).
affects: 0.12.0+
breakingThe `enqueue_on_commit` functionality was removed in version `0.10.0`.
fix
Tasks should be enqueued directly using `.delay()`. If deferred execution within a transaction is required, you will need to implement custom transaction management logic or use a different mechanism.
affects: 0.10.0+
breakingIn version `0.8.0`, the `TaskResult` status `NEW` was renamed to `READY` to better support retry functionality. Additionally, exceptions and tracebacks are now stored in a `.errors` list on the `TaskResult` model, rather than directly on `exception` and `traceback` attributes.
fix
Update any code referencing `TaskResult.status == 'NEW'` to `TaskResult.status == 'READY'`. Access exceptions and tracebacks via the `task_result.errors` list (e.g., `task_result.errors[0].exception_class`, `task_result.errors[0].traceback`).
affects: 0.8.0+
breakingIn version `0.6.0`, the `TaskResult` status `completed` was renamed to `succeeded`.
fix
Update any code referencing `TaskResult.status == 'completed'` to `TaskResult.status == 'succeeded'`.
affects: 0.6.0+
Upgrade
Version history
0.12.0latest on PyPI · released Feb 6, 2026
Audit
Dependencies
django-tasks-dboptionalRequired for using the Database backend (if not already installed with core `django-tasks`).
django-tasks-rqoptionalRequired for using the RQ backend (if not already installed with core `django-tasks`).
Agent activity
36 hits · last 30 days
node
30
OpenAI (training)
1
Resources
django-tasks — pip install django-tasks · libregistry