Django 6 task enqueue

Django's built-in Tasks API with aenqueue, immediate jobs and a dummy queue.

Run with Docker

From the repository root:

docker compose -f examples/compose.yaml up --build --wait tasks-django6
docker compose -f examples/compose.yaml exec tasks-django6 python manage.py check

The API is available on http://127.0.0.1:8111. See container setup for port overrides, required services, optional profiles, tests and data retention. The commands below run the same application directly with uv.

Run

From this directory (Python 3.12+ and uv):

uv venv
uv pip install --python .venv/bin/python -r pyproject.toml --group test -e ../..
uv run --no-sync python manage.py check
uv run --no-sync uvicorn project.asgi:application --host 127.0.0.1 --port 8111

Change --host and --port as needed. For another hostname also set EXAMPLE_ALLOWED_HOSTS=localhost,127.0.0.1,your-host. The default is loopback. This project depends on this checkout through [tool.uv.sources]; it does not import another example. Its virtual environment and SQLite database are local.

Requests

curl -X POST http://127.0.0.1:8111/enqueue/ -H 'Content-Type: application/json' -d '{"value":4}'
curl -X POST http://127.0.0.1:8111/queue/ -H 'Content-Type: application/json' -d '{"value":4}'

Tests

uv run --no-sync pytest -q

The tests send requests through the project's ASGI application, with lifespan startup/shutdown. Database tests use an isolated test database.

Compatibility and limits

ImmediateBackend runs before the HTTP response; DummyBackend records without execution. Neither is a durable production queue. Choose and operate a production backend/worker separately. Enqueue after database commit when the job reads rows created by the request. No task wrapper, import shim or worker is installed by aiodrf.

The endpoints are public and the settings use a development secret key: do not deploy this project as it is. See the feature guide and example catalogue for related examples.