Rust-powered HTTP, msgspec serialization, full type validation β
with the Django ORM, Django Admin, and every Django package you already use.
Documentation Β· Quick Start Β· Features Β· Benchmarks Β· Video Tutorial Β· Discord
Django-Bolt is the fastest Python web framework: 300k+ requests/second on a single 12-core desktop (8 processes, C=100, loopback), ahead of FastAPI and Robyn, and even of Bun-based JavaScript frameworks (Elysia, Hono) on JSON payloads. It is a fully typed API framework for Django. It serves your endpoints from a Rust HTTP server (Actix Web + Tokio), bridges to your Python handlers with PyO3, and serializes with msgspec β while everything you love about Django (ORM, Admin, auth, middleware, signals, third-party apps) keeps working out of the box.
Think Django REST Framework or Django Ninja, with a Rust engine underneath and no gunicorn or uvicorn required.
from django_bolt import BoltAPI
api = BoltAPI()
@api.get("/hello/{name}")
async def hello(name: str):
return {"message": f"Hello, {name}!"}python manage.py runbolt --dev| β‘ Rust speed, Python ergonomics | HTTP parsing, routing, auth, guards, CORS, rate limiting, and compression run in Rust without touching the GIL. Your handlers stay plain Python. |
| π 100% Django | Use your existing models, settings.py, INSTALLED_APPS, Django Admin, middleware, and signals. Migrate one endpoint at a time from DRF. |
| π§· Fully typed | Type hints drive path/query/header/cookie/form/body extraction and validation. msgspec.Struct and Bolt Serializer return types are validated on the way out. |
| π Deploy directly | runbolt is the production server: multi-process with SO_REUSEPORT, worker recycling, graceful shutdown, static & media serving. |
| π Batteries included | OpenAPI docs (Swagger, ReDoc, Scalar, RapiDoc, Stoplight), JWT/API-key auth, guards, pagination, ViewSets, WebSockets, SSE, streaming, testing client, MCP servers. |
pip install django-bolt # or: uv add django-bolt# myproject/settings.py
INSTALLED_APPS = [
...,
"django_bolt",
]Create an api.py next to your settings.py (or inside any Django app β Bolt autodiscovers them all):
# myproject/api.py
import msgspec
from django.contrib.auth import get_user_model
from django_bolt import BoltAPI
User = get_user_model()
api = BoltAPI()
class UserSchema(msgspec.Struct):
id: int
username: str
@api.get("/users/{user_id}")
async def get_user(user_id: int) -> UserSchema: # response is type-validated
user = await User.objects.aget(id=user_id) # Django ORM, no extra setup
return {"id": user.id, "username": user.username}python manage.py runbolt --dev # auto-reload for development
python manage.py runbolt --processes 4 # production: multi-process, no gunicorn/uvicornYour API is live at http://localhost:8000/users/1 and interactive docs at http://localhost:8000/docs.
π Next: the Quick Start guide β Deployment β Topic guides.
Request validation with type hints
import msgspec
from typing import Annotated
from django_bolt import BoltAPI
from django_bolt.param_functions import Header
api = BoltAPI()
class CreateUser(msgspec.Struct):
username: str
email: str
@api.post("/users", status_code=201)
async def create_user(
user: CreateUser, # JSON body β validated struct
api_key: Annotated[str, Header("x-api-key")], # header
page: int = 1, # query param with default
):
return {"username": user.username, "page": page}Authentication & guards (evaluated in Rust)
from django_bolt.auth import JWTAuthentication, IsAuthenticated, Requires
IsStaff = Requires("is_staff", True)
@api.get("/admin/stats", auth=[JWTAuthentication()], guards=[IsAuthenticated(), IsStaff])
async def admin_stats(request):
return {"user_id": request.user.id}JWT signature checks, expiry, API-key lookup, and guard evaluation all happen before the GIL is ever taken.
Serializers & ModelViewSet
from django_bolt import ModelViewSet, PageNumberPagination
from django_bolt.serializers import Serializer
from myapp.models import Article
class ArticleSchema(Serializer):
id: int
title: str
content: str
class Config:
field_sets = {"list": ["id", "title"]}
@api.viewset("/articles")
class ArticleViewSet(ModelViewSet):
queryset = Article.objects.all()
serializer_class = ArticleSchema
pagination_class = PageNumberPaginationOne Serializer class, many projections β no more UserListSerializer / UserDetailSerializer / UserAdminSerializer sprawl.
WebSockets & Server-Sent Events
from django_bolt import WebSocket, StreamingResponse
@api.websocket("/ws/echo")
async def echo(websocket: WebSocket):
await websocket.accept()
async for message in websocket.iter_text():
await websocket.send_text(f"Echo: {message}")
@api.get("/events")
async def events():
async def stream():
for i in range(10):
yield f"data: tick {i}\n\n"
return StreamingResponse(stream(), media_type="text/event-stream")MCP servers for LLM clients
from bolt_mcp import MCP # pip install "django-bolt[mcp]"
mcp = MCP("my-server")
@mcp.tool
async def add(a: int, b: int) -> dict:
return {"sum": a + b}
api.mount_mcp(mcp)Expose tools, resources, and prompts over MCP Streamable HTTP, backed by the official Rust SDK.
Middleware: CORS, rate limiting, compression
from django_bolt.middleware import cors, rate_limit
@api.get("/public")
@cors(origins=["https://example.com"])
@rate_limit(rps=100, burst=200)
async def public():
return {"ok": True}Django middleware (sessions, messages, CSRF, your own) is supported too.
| Feature | Description |
|---|---|
| β‘ High Performance | Actix Web + Tokio + PyO3, zero-copy routing, sync-dispatch bypass for simple handlers |
| π Authentication | JWT, API key, and Django session auth β validated in Rust |
| π‘οΈ Permissions & Guards | IsAuthenticated, AllowAny, and claim-based Requires(...) guards |
| ποΈ Middleware | CORS, rate limiting, compression, Django middleware integration |
| π¦ Serializers | msgspec-based validation with field sets, computed fields, and model integration |
| ποΈ Async ORM | Return QuerySets from async handlers; bounded, vendor-aware ORM executor |
| π‘ Responses | JSON, HTML, redirects, files, streaming, SSE |
| π WebSockets | FastAPI-style WebSocket handlers on Rust infrastructure |
| π OpenAPI | Auto-generated schema with Swagger, ReDoc, Scalar, RapiDoc, and Stoplight UIs |
| π§± Class-Based Views | APIView, ViewSet, ModelViewSet, @action |
| π Pagination | PageNumber, LimitOffset, and Cursor pagination |
| π Dependency Injection | Depends(...) with registration-time graph resolution |
| π€ MCP Servers | Tools, resources, prompts, and streaming over MCP Streamable HTTP |
| ποΈ Static & Media Files | Native Rust static/media serving β no WhiteNoise needed |
| π ASGI Mounts | Mount existing ASGI apps under a prefix |
| π©Ί Health, Logging, Lifespan | Health endpoints, structured logging, lifespan hooks, signals |
| π§ͺ Testing | In-process TestClient that runs the full Rust pipeline |
| 𧬠Nanodjango | Single-file Django apps |
All runtime settings and environment variables are listed in the Settings reference.
Measured with bombardier on a single 12-core desktop (Ryzen 5 5600G), loopback, C=100, N=100000, 8 processes Γ 1 worker (runbolt --processes 8). Absolute numbers are hardware-specific; run just save-bench to reproduce on your machine. Full results: python/benchmark/BENCHMARK.md.
| Endpoint | Requests/sec | p99 latency |
|---|---|---|
Root JSON ({"message": ...}) |
~311,000 | 2.2 ms |
Path + query params (/items/1?q=hello) |
~264,000 | β |
PUT JSON body (/items/1) |
~257,000 | β |
| JSON parse + validate (POST) | ~251,000 | β |
| Form data (POST) | ~218,000 | β |
| 10 KB JSON response | ~187,000 | 2.2 ms |
| File upload (multipart) | ~178,000 | β |
| JWT-authenticated (no DB) | ~160,000 | β |
| Static 1 KB asset | ~159,000 | β |
| ORM list, 10 rows (SQLite, async) | ~21,000β27,000 | β |
Server-Sent Events, 10,000 concurrent clients for 60 s: 9,489 msg/s, 100% connections succeeded, ~236 MB RSS, 11.9% average CPU.
The same JSON payloads served by Django-Bolt, Elysia (Bun), and Hono (Bun & Node), 8 processes each:
| Payload | Django-Bolt | Elysia / Bun | Hono / Bun | Hono / Node |
|---|---|---|---|---|
| 1 KB JSON | 251k | 264k | 210k | 97k |
| 10 KB JSON | 157k | 124k | 111k | 79k |
- Actix Web + Tokio handle HTTP parsing and responses; matchit routes with zero-copy path matching.
- Auth, guards, CORS, rate limiting, compression run in Rust β no GIL, no Python per-request overhead.
- msgspec serialization is 5β10Γ faster than the standard library; response bodies cross to Rust zero-copy.
- Sync-dispatch bypass: handlers that don't actually await are detected at registration and skip the async bridge entirely.
- Registration-time precomputation: parameter extraction, dependency graphs, and middleware are compiled once, reused forever.
HTTP request
β
βΌ
Actix Web (Rust) ββ routing (matchit) ββ CORS Β· rate limit Β· compression
β
βΌ
Auth & guards (Rust, no GIL) ββ JWT / API key / session Β· IsAuthenticated Β· Requires(...)
β
βΌ
Dispatch ββ sync fast path (single GIL block) or async path (persistent worker loop)
β
βΌ
Your handler ββ typed params Β· Depends(...) Β· Django ORM
β
βΌ
msgspec serialization ββ zero-copy body ββ HTTP response
python manage.py runbolt --host 0.0.0.0 --port 8000 --processes 4
python manage.py runbolt --processes 4 --max-rss 512 # recycle workers above 512 MBMulti-process scaling uses SO_REUSEPORT for kernel-level load balancing. Worker recycling, crash respawn, graceful shutdown, and WebSocket drain are built in. See the Deployment guide for systemd, supervisor, and reverse-proxy setups.
Contributions are welcome! See CONTRIBUTING.md for the development setup (Rust toolchain, uv, just), the test workflow, and pull request guidelines.
git clone https://github.com/dj-bolt/django-bolt.git && cd django-bolt
uv sync && just build && just test-py- π Documentation
- π¬ Discord
- π Issues
- π₯ Video walkthrough by BugBytes
- π€ Ask DeepWiki Β· for AI assistants: llms.txt
- β FAQ Β· Comparison vs Ninja / DRF / FastAPI / Litestar Β· How it works
Support Django-Bolt's development by becoming a sponsor. Your logo will appear here with a link to your website.
Django-Bolt stands on the shoulders of giants:
- Django REST Framework β ViewSet patterns, permission system, and overall API philosophy
- FastAPI β dependency injection, parameter extraction, and type-hint-driven design
- Litestar β OpenAPI plugin architecture, middleware and guard design
- Robyn β proved the potential of Rust-powered Python web frameworks with PyO3
- Actix Web, PyO3, msgspec, matchit β the foundations that make the speed possible
Django-Bolt is released under the MIT License.