Skip to content

Open source · MIT · Python 3.12+

Django APIs on a Rust server.

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

articles/api.py

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

Measured against Litestar and FastAPI

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

Django-Bolt 43,541
Litestar 15,477
FastAPI 7,517

10 KB JSON response

Django-Bolt 27,610
Litestar 12,925
FastAPI 1,805

JWT auth, then load the user

Django-Bolt 4,478
Litestar 1,155
FastAPI 941

10 rows from PostgreSQL

Django-Bolt 2,881
Litestar 1,321
FastAPI 1,237

Requests per second, median of two runs, 2026-08-30, Python 3.14, bombardier. Conditions, more endpoints and how to reproduce.

How it works

Rust does the work around your handler

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.

  1. RustHTTPActix Web parses the request
  2. RustRoutingA radix tree finds the route
  3. RustCORS and rate limitsPreflights and limits end here
  4. RustAuth and guardsJWT and API keys are checked
  5. PythonYour handlerTyped arguments, Django ORM
  6. RustResponsemsgspec bytes, compression

Read how a request moves through Bolt.

Still Django

Keep the project you have

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.

Migrate from Ninja, DRF or FastAPI →

You keep

  • Models, migrations and the ORM
  • The admin
  • settings.py and your apps
  • Users, groups and permissions
  • Signals and Django middleware
  • Templates and the test runner

Bolt adds

  • A Rust HTTP server, many processes
  • Typed parameters, checked by msgspec
  • JWT and API-key auth in Rust
  • OpenAPI docs at /docs
  • WebSocket and server-sent events
  • MCP servers for LLM clients

Examples

The code you write

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

Add Bolt to your Django project

Install the package, add one app, and run one command.