Open source · MIT · Python 3.12+
Write typed handlers in Python. Django-Bolt serves them from Actix Web and runs routing, authentication, CORS and rate limits in Rust before your code starts. Your models, admin and migrations do not change.
pip install django-bolt
import msgspec
from django_bolt import BoltAPI
from .models import Article
api = BoltAPI()
class ArticleOut(msgspec.Struct):
id: int
title: str
@api.get("/articles")
async def list_articles(limit: int = 20) -> list[ArticleOut]:
return Article.objects.order_by("-id")[:limit]
$ python manage.py runbolt --dev
$ curl localhost:8000/articles?limit=2
[{"id":42,"title":"Hello, Bolt"},{"id":41,"title":"Typed routes"}]
324,493
requests per second for a JSON route. 8 processes, 100 connections, one desktop CPU.
2.8×
the throughput of Litestar and 5.8× FastAPI on a 1 KB JSON response, one process each.
1 command
manage.py runbolt is the production server. No gunicorn, no uvicorn.
Benchmarks
Same machine, same PostgreSQL data, one process per framework, 100 connections. Higher is better. Each framework uses its usual stack: Django ORM for Bolt, SQLAlchemy with asyncpg for the others.
1 KB JSON response
10 KB JSON response
JWT auth, then load the user
10 rows from PostgreSQL
Requests per second, median of two runs, 2026-08-30, Python 3.14, bombardier. Conditions, more endpoints and how to reproduce.
How it works
Bolt rejects a bad token or a request over the rate limit in Rust, and it answers each CORS preflight. With no Python middleware, Python runs only for a request that reaches your handler.
Still Django
Bolt is a Django app. Add it to INSTALLED_APPS, write routes in
api.py, and start the server with manage.py.
Move one endpoint at a time from Django REST Framework or Django Ninja.
settings.py and your apps/docsExamples
class ArticleIn(msgspec.Struct):
title: str
body: str
tags: list[str] = []
@api.post("/articles", status_code=201)
async def create_article(article: ArticleIn):
return {"title": article.title, "tags": article.tags}
# POST /articles {"title": 1}
422 {"detail": [{"loc": ["body", "title"],
"msg": "Expected `str`, got `int`", "type": "validation_error"}]}
Bolt reads each argument from its type hint. A bad body never reaches the handler. Requests guide
from django_bolt.exceptions import NotFound
@api.get("/users/{user_id}")
async def get_user(user_id: int) -> UserOut:
user = await User.objects.filter(id=user_id).afirst()
if user is None:
raise NotFound(detail="User not found")
return user
Use the async ORM, or return a QuerySet. Bolt runs the query on a bounded thread pool and encodes each row to the return type. Django ORM guide
from django_bolt.auth import IsAuthenticated, JWTAuthentication
@api.get("/me", auth=[JWTAuthentication()], guards=[IsAuthenticated()])
async def me(request):
user = await request.auser()
return {"username": user.username}
# GET /me (no token)
401 {"detail": "Authentication required"}
Rust checks the token signature, the expiry and the guards. A request without a valid token does not start Python. Authentication guide
from django_bolt.websocket import WebSocket
@api.websocket("/ws/echo")
async def echo(websocket: WebSocket):
await websocket.accept()
async for message in websocket.iter_text():
await websocket.send_text(message.upper())
WebSocket routes use the same auth, guards and CORS rules as HTTP routes. WebSocket guide
Documentation
Build an articles API in four parts: routes, models, authentication, tests.
Do one task: validate a body, paginate a list, add CORS, stream events.
Every class, argument, default and setting, taken from the source.
Run many processes, recycle workers, and put Bolt behind nginx.
Bolt next to Django Ninja, DRF, FastAPI and Litestar, with its weak points.
Production use, supported versions, WSGI and ASGI, and how to get help.
Install the package, add one app, and run one command.