Writing
Django vs Rails: Which Framework Should a Company Choose for a Web App and API?
Pick the framework your team already knows, because deadlines beat benchmarks. I lean Rails for speed to market, Django for Python teams and admin-heavy apps, and a Python service for ML either way.
By Ka Lun Chan · Web development / Engineering judgment
Should a company build its web app and API with Django or Rails?
Pick the framework your team already knows, because deadlines matter more than framework benchmarks. With no existing preference, I lean Rails for getting a web product to market quickly and Django when the team writes Python or needs a strong admin. If the product depends on machine learning, keep that work in a Python service either way.
I first wrote this on my old blog. This version keeps the business reasoning that held up, drops the job-board numbers that didn’t, and corrects a couple of claims I overstated.
I’m only looking at this from the business side: which choice gets a working product in front of customers, and which one you can staff and grow. Both frameworks are mature, well documented and used at very large scale. The wrong choice is rarely fatal. Reinventing the wheel, or picking a stack nobody on the team knows, is what burns the deadline.
| Situation | Lean toward | Why |
|---|---|---|
| MVP on a tight deadline, team knows Ruby | Rails | Conventions and gems get a working product out fastest |
| Team already writes Python | Django | Retraining costs more than any framework advantage |
| Lots of internal data editing and back-office work | Django | The admin gives you a working back office from your models |
| API-only backend with typed request contracts | FastAPI, DRF or Rails in API mode | All three are mature; pick the language your team knows |
| Product that trains or runs its own models | Either for the app, plus a Python service | Keep the ML work in Python, where the tooling lives |
| App that only calls a hosted LLM API | Either | Official SDKs exist for both Python and Ruby |
| Hard-to-fill roles in your market | Whichever you can staff | Check your local job market before you commit |
Which framework gets an MVP to market faster?
In my opinion, Rails, for a team that knows it. Its conventions and gem ecosystem cut the number of decisions and the amount of code. Django has real advantages of its own, though, especially the admin, so the gap is smaller than I once claimed.
When I first wrote this, I said Rails makes web application and API development much faster than Django. I still lean that way, but that’s my opinion from building with Rails, not a measured fact. For a start-up trying to get a minimum viable product out, speed to market is the point, and Rails is built around it. The Rails Doctrine puts convention over configuration near the top, and for most common problems there’s a gem that already solves it. I’ve written up the Ruby gems I reach for separately.
The counterpoint deserves equal weight:
- The Django admin reads your models and gives trusted staff a working interface to manage data. Django’s docs say it’s meant for internal management, not your whole front end, and for that job it saves weeks.
- Django REST framework is a mature toolkit for APIs, with serialization, authentication and a browsable API.
- FastAPI has become a common choice for Python APIs. It builds validation and OpenAPI documentation from standard type hints.
Rails covers the API-only case too. Rails in API mode starts with a slimmer middleware stack and skips views and assets. Whichever side you pick, the team’s fluency will matter more than these feature lists.
Is Python a good choice for web development?
Yes. I originally wrote that Python is not an ideal choice for web development, and that was overstated. Python web frameworks are mature and run some of the largest sites on the internet. What I meant was narrower: Ruby’s community grew up around the web, while Python’s spread across data science and machine learning too.
Both are general-purpose languages. Ruby found its main role through Rails, so the gems, tutorials and hiring pool lean heavily toward web applications and APIs. Python’s community is larger and spread wider, across scripting, data, science and ML. That breadth is why Django’s web-specific ecosystem can feel smaller than Rails’ even though Python itself is bigger.
Which large companies use Rails and Django?
GitHub and Shopify are the clearest Rails examples, confirmed by their own engineering blogs. Instagram is the best-known Python and Django example. Treat any “built with” list as a snapshot, because large companies change stacks over time.
My original post had long lists of sites built with each framework. I’ve cut them to the ones I could confirm from first-party sources:
- GitHub’s engineering blog says GitHub.com has been a Ruby on Rails monolith from the beginning, and that it tracks the Rails main branch with a weekly upgrade.
- Shopify Engineering describes its core monolith as one of the oldest and largest Rails codebases around.
- Engineering at Meta describes the millions of lines of Python behind Instagram’s servers, and says Meta uses Django and Tornado for its own products.
None of this should decide your choice. These companies have engineering teams far larger than yours, and they made the call years ago for their own reasons.
Does the framework decide how fast the app is?
Much less than people expect. Language, framework, web server, database and caching all affect performance, and in most web apps the database and caching dominate. A well-built Rails app and a well-built Django app can both be fast.
This point from the original held up. Slow pages usually come from slow queries, missing indexes or nothing cached, not from Ruby or Python. I go into that in database performance and caching. Choose the framework for delivery speed and staffing, then spend your performance effort on the data layer.
Is it easier to hire Rails or Django developers?
It depends on your market, so check it yourself before committing. When I first wrote this, Rails roles far outnumbered Django roles in the job listings I looked at. Those numbers are long out of date, and job-board counts change daily, so I’ve dropped them.
The career question I raised still matters for retention. Career advancement is one of the biggest reasons people stay or leave. My view then, which I still hold as an opinion, was that a Python web developer is likely to be pulled toward machine learning, while a Rails developer is more likely to move into modern front-end work with React, keeping Rails as the backend. I cover that pairing in React on Rails.
So ask how many of your Python developers want to build web applications and APIs for the long run, versus moving into ML and data work. If the answer is “most want ML,” plan for that path instead of fighting it.
One piece of my own background, since it bears on my bias: when I was CTO of a media publishing platform, I led a re-platform of a portfolio of titles from WordPress to Ruby on Rails on AWS.
Can you use Rails for the app and Python for machine learning?
Yes, and it’s often the best of both. Build the product in the framework your team ships fastest with, and put model training, evaluation and inference in a small Python service behind an API. Python’s ML and model tooling makes that split stronger now than when I first suggested it.
The ML ecosystem is Python-first. Libraries such as Hugging Face Transformers are where new models, training code and inference tooling show up. If your product fine-tunes models, runs its own, or needs evaluation pipelines, that code belongs in Python.
Don’t over-apply it, though. If the app only calls a hosted model through an API, you may not need Python at all. Anthropic, for example, publishes official client SDKs for both Python and Ruby. A separate service adds deployment, monitoring and a network hop, so it has to earn its place. I’ve written about that tradeoff in should it be a microservice.
When it does earn its place, keep the contract small. Here the Rails app calls a Python scoring service with timeouts and a clear failure:
# app/services/sentiment_client.rb
require "net/http"
require "json"
class SentimentClient
ENDPOINT = URI(ENV.fetch("ML_SERVICE_URL") + "/score")
def self.score(text)
Net::HTTP.start(ENDPOINT.host, ENDPOINT.port,
use_ssl: ENDPOINT.scheme == "https",
open_timeout: 2, read_timeout: 5) do |http|
request = Net::HTTP::Post.new(ENDPOINT, "Content-Type" => "application/json")
request.body = { text: text }.to_json
response = http.request(request)
raise "ML service returned #{response.code}" unless response.is_a?(Net::HTTPSuccess)
JSON.parse(response.body)
end
end
end# ml_service/main.py
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class ScoreRequest(BaseModel):
text: str
class ScoreResponse(BaseModel):
label: str
score: float
@app.post("/score")
def score(req: ScoreRequest) -> ScoreResponse:
label, confidence = predict(req.text) # your model code
return ScoreResponse(label=label, score=confidence)Call it from a background job where you can, so web requests stay fast while the model works. Give the ML service a named owner, a separate deploy pipeline and an evaluation suite, because it changes on a different rhythm from the product.
Sources
Checked in November against GitHub’s and Shopify’s engineering blogs, Engineering at Meta, the Django, Django REST framework, FastAPI and Rails documentation, the Rails Doctrine, the Hugging Face Transformers docs and Anthropic’s SDK list. The decision table, the code and the opinions are mine.
- GitHub Blog: Building GitHub with Ruby and Rails
- Shopify Engineering: The state of Shopify’s monolith
- Engineering at Meta: Pysa, static analysis for Python code (Instagram, Django)
- Django Docs: The Django admin site
- Django REST framework
- FastAPI documentation
- Ruby on Rails Guides: Using Rails for API-only Applications
- The Rails Doctrine
- Hugging Face Docs: Transformers
- Anthropic Docs: Client SDKs
Short answers
Is Rails faster than Django for building an MVP?
In my opinion, yes, for a team that knows Ruby, because Rails conventions and gems cut decisions and code. Django narrows the gap with its built-in admin, Django REST framework and, for APIs, FastAPI. The team’s existing skills matter more than either framework.
Is Python a good language for web development?
Yes. Django, FastAPI and other Python frameworks are mature, and Meta describes millions of lines of Python behind Instagram’s servers. Ruby’s community is more web-focused, while Python’s is larger and spread across data science and machine learning too.
Which big companies use Rails or Django?
GitHub and Shopify both describe large Rails monoliths on their engineering blogs. Instagram is the best-known Python and Django example. Treat any list like this as a snapshot, because companies change stacks over time.
Should I use Rails for the app and Python for machine learning?
Often, yes. Build the product in the framework your team ships fastest with, and put model training, evaluation and inference in a small Python service behind an API. If the app only calls a hosted LLM API, official SDKs exist for Ruby as well as Python, so a separate service may not be needed.
Make the call in a day
Write down what your team already knows, whether you need an admin, whether you’ll run your own models, and who you can hire locally. Run those answers through the table and commit, then spend the saved time on the product.