Skip to content
All notes
4 min read

Django is a better AI backend than people expect

The AI backend conversation defaults to whatever is newest. Most of what an LLM feature needs, Django already had in 2010.

Every AI feature I've shipped ended up needing the same unglamorous list: durable records of what was asked and answered, a job queue for anything slower than a request, per-user quotas, an admin surface so someone non-technical can look at bad outputs, and migrations for the schema that will change five times.

That list is Django's home turf. It is strange how rarely it comes up.

What the model needs is not the hard part

Calling an LLM is an HTTP request. It is the least interesting code in the system and it will be a small file no matter which framework surrounds it.

What takes the time is everything around it: storing the conversation, associating it with a user, retrying the failures, rate limiting the abuse, and giving support staff a way to see what happened when a customer complains. A framework that hands you the ORM, the migrations, the admin, and the auth is doing more for that list than one that hands you a faster router.

Where it does need help

Django's request/response cycle is synchronous by default, and LLM calls are slow enough that tying up a worker for twenty seconds is real. That's what the task queue is for — the request enqueues, the worker calls the model, the client polls or subscribes.

Streaming is the genuine friction point. It's workable with ASGI, but it's the part where the framework stops helping and you're wiring things yourself. If the product is streaming-first end to end, that's a legitimate reason to reach elsewhere.

The actual criterion

Pick the backend by what the feature is mostly made of. If it's mostly model calls with a thin shell around them, use whatever is thinnest. If it's a product with users, billing, permissions, and an audit trail that happens to call a model — that's a web application, and Django has been very good at web applications for a long time.