Durable workflows for Django.
Project description
Django Hookflow
Durable workflows for Django, powered by Upstash QStash and Django QStash
Installation
uv add django-hookflow
or
pip install django-hookflow
Requirements:
- Python 3.10+
- Django 4.2+
Features
- Durable Workflows: Multi-step workflows that survive restarts and failures
Quick Start
Define workflows with steps that automatically checkpoint their progress. If a step fails or the server restarts, the workflow resumes from where it left off.
# app/workflows.py
from django_hookflow import workflow
@workflow
def process_order(ctx):
order_id = ctx.data.get("order_id")
# Each step is executed exactly once, even across retries
validated = ctx.step.run("validate", validate_order, order_id)
# Durable sleep - doesn't consume server resources
ctx.step.sleep("wait-for-payment", seconds=60)
# Make HTTP calls with automatic retry and caching
payment = ctx.step.call("charge", url="https://api.stripe.com/...", method="POST")
result = ctx.step.run("fulfill", fulfill_order, order_id, payment)
return {"status": "completed", "result": result}
Trigger workflows programmatically:
# Trigger returns immediately, workflow runs asynchronously
run_id = process_order.trigger(data={"order_id": "12345"})
Configuration
Add to your Django settings:
QSTASH_TOKEN = "your-qstash-token"
DJANGO_HOOKFLOW_DOMAIN = "https://your-app.com"
DJANGO_HOOKFLOW_WEBHOOK_PATH = "/hookflow/" # optional, defaults to /hookflow/
Add the webhook URLs to your urls.py:
from django.urls import include, path
urlpatterns = [
path("hookflow/", include("django_hookflow.urls")),
]
Workflow Context API
Inside a workflow function, ctx provides:
| Property | Description |
|---|---|
ctx.data |
Initial payload passed to .trigger() |
ctx.run_id |
Unique identifier for this workflow run |
ctx.workflow_id |
The workflow's identifier |
ctx.step |
Step manager for durable operations |
Step Manager Methods
| Method | Description |
|---|---|
ctx.step.run(step_id, fn, *args, **kwargs) |
Execute a function as a durable step |
ctx.step.sleep(step_id, seconds) |
Sleep without consuming resources |
ctx.step.call(step_id, url, method, body, headers) |
Make a durable HTTP request |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_hookflow-0.0.2.tar.gz.
File metadata
- Download URL: django_hookflow-0.0.2.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fef276d92f29463f496dabb913307de687d8f76a0807d239094be1827e8aa587
|
|
| MD5 |
8ca6382d9e3c1aa05a63577bc9520522
|
|
| BLAKE2b-256 |
042fa047e2add38a0a19db6023e9ddc805066e5e63f464d31a24909b99c12715
|
Provenance
The following attestation bundles were made for django_hookflow-0.0.2.tar.gz:
Publisher:
main.yaml on jmitchel3/django-hookflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_hookflow-0.0.2.tar.gz -
Subject digest:
fef276d92f29463f496dabb913307de687d8f76a0807d239094be1827e8aa587 - Sigstore transparency entry: 834332297
- Sigstore integration time:
-
Permalink:
jmitchel3/django-hookflow@e2604c130bceda2713e4145c05040d64a84a0207 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/jmitchel3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yaml@e2604c130bceda2713e4145c05040d64a84a0207 -
Trigger Event:
push
-
Statement type:
File details
Details for the file django_hookflow-0.0.2-py3-none-any.whl.
File metadata
- Download URL: django_hookflow-0.0.2-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e2d5ea35c903bb10af69227b6554e3bd5f8e2df7c7b71321726cad24fc5cd9
|
|
| MD5 |
3151ba6e8006888d4ee970add290bad6
|
|
| BLAKE2b-256 |
4f634d075cdfb1e8a112e3b6361f45a2aee85c048efdd30d73e878e76a9f8502
|
Provenance
The following attestation bundles were made for django_hookflow-0.0.2-py3-none-any.whl:
Publisher:
main.yaml on jmitchel3/django-hookflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_hookflow-0.0.2-py3-none-any.whl -
Subject digest:
f6e2d5ea35c903bb10af69227b6554e3bd5f8e2df7c7b71321726cad24fc5cd9 - Sigstore transparency entry: 834332301
- Sigstore integration time:
-
Permalink:
jmitchel3/django-hookflow@e2604c130bceda2713e4145c05040d64a84a0207 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/jmitchel3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main.yaml@e2604c130bceda2713e4145c05040d64a84a0207 -
Trigger Event:
push
-
Statement type: