Where Django shines and where Rails shines: find your product's centre of gravity

TL;DR

Difficulty: Beginner

Pick by your product's centre of gravity, not by feature lists.

  • Django has a documented head start for back office, data and content work: the automatic admin, Python's data libraries, Wagtail and Django REST framework.
  • Rails has one for live interfaces and for shipping a whole product with a small team: one integrated stack, Hotwire and Action Cable, generators, Solidus for shops.
  • Most business applications sit in the middle, where both are equally good and the team should decide.
  • Strengths have a half life: some pay off on day one and fade, others arrive in year three. Score the horizon you care about.

Django or Rails is usually argued as a matter of taste. It is more useful to ask which kinds of product each one gives a real head start, and when that head start stops mattering. Here is a map of strengths, each backed by the documentation or the companies' own words, tested on one example business.

The question behind "which one is better"

Ask a room of developers whether Django or Rails is better and you will get a long, friendly argument and no answer. That is because the question is wrong. Both are mature, open source, "batteries included" web frameworks. Both run very large products. Both will build a booking system, a shop or a back office without complaint. The first chapter of this series showed that the deep difference between them is philosophy: Rails infers what it can by convention, Django asks you to state it explicitly.

So the useful question is narrower: for which kinds of product does each one give you a real head start, and where does that head start stop mattering? This chapter answers it with an honest map of strengths. Every strength is tied to something you can check, a page in the official documentation, a release note or a company's own engineering blog. Where the two are equally good, I say so. Where neither is the best first choice, I say that too and name the alternatives.

One disclosure before we start, because it matters in a comparison. I build web applications and online shops on Ruby on Rails. I do not build Django applications for clients. I have tried hard to write every Django section so that a senior Django developer would sign it off, and where something is my judgement rather than documented fact, I label it.

The example running through the whole series is invented: Cogwell Cycles, a chain of six bicycle repair workshops in Sheffield. Its founder, Hannah, wants to replace a tangle of spreadsheets and a rented booking widget with her own web application. Her two developers, Priya and Owen, will build it. Priya has four years of Python (data analysis, a little Flask), Owen three years of JavaScript and TypeScript with React. Neither has used Ruby. They have six months for the first version.

Find your product's centre of gravity

Here is the rule of thumb I want you to take away, and the rest of the chapter is evidence for it. Every web application does four kinds of work, in different proportions:

  • Back office work: staff looking up, correcting and approving records.
  • Data work: analysing, forecasting and modelling what the records mean.
  • Content work: editors writing, structuring and publishing pages.
  • Interaction work: customers and staff clicking through screens that react quickly, update live and feel like an app.

Every product needs some of all four. But one of them is usually where the product earns its money and where most of the hard days will be spent. That is its centre of gravity. My view, which I will argue section by section: Django's documented strengths cluster around back office, data and content work, and Rails' documented strengths cluster around interaction work and around shipping a whole product with a small team. When a product's centre of gravity sits clearly in one of those clusters, the matching framework gives a real head start. When it sits in the middle, which is where most business applications sit, the choice is close and should be made on the team rather than the product.

There is a second half to the rule, and it is the one people miss. Strengths have a half life. Some strengths pay off in the first week and then fade, because the product outgrows them. Others pay off only in year two or three, when the product needs something it did not need at launch. A fair comparison asks not only "which strengths does my product need?" but "when?".

Kind of workWhere it pays offFramework with the documented head start
Back officeDay one, fades as staff screens become customDjango (the automatic admin)
Data and machine learningYear two or three, grows over timeDjango (Python's scientific ecosystem)
Content and publishingFrom launch, steadyDjango (newsroom origin, Wagtail)
Interaction and live updatesFrom launch, grows with usersRails (Hotwire and Action Cable in the default stack)
Whole product with a small teamFirst year, steadyRails (one integrated stack, generators)
Ordinary records, forms and reportsAlwaysNeither: a tie

Example: sorting Hannah's list

Hannah's list of what the application must do, sorted by kind of work and by when it is needed:

NeedKind of workWhen
Online booking with a time slot per mechanicInteractionFirst version
Live workshop board (job cards move between "waiting", "in repair", "ready")InteractionFirst version
Job cards with before and after photosInteraction and recordsFirst version
Parts stock and a nightly reorder reportRecords and dataFirst version
"Your bike is ready" by email and SMSRecordsFirst version
Back office for managersBack officeFirst version
Invoices with VATRecordsFirst version
ReportingDataFirst version
A small mobile app for mechanicsInteraction (an API)Later
A demand forecast for partsDataLater

Read down the "kind of work" column and you can already see the tension. The first version leans towards interaction: booking, a live board, photos. The later needs lean towards data: reporting and a forecast. Cogwell's centre of gravity moves over time. Keep that in mind, because it will decide the score at the end of the chapter.

Where Django shines: a working back office on day one

The single most distinctive thing Django gives you is the admin. The documentation opens its page on it with a claim that the community has never had to defend: "One of the most powerful parts of Django is the automatic admin interface."1 Django reads the structure of your models (the Python classes that describe your database tables) and builds a complete, secure set of screens for listing, searching, filtering, creating and editing records. You write a few lines of configuration, not a single template.

Django 5.0, released on 4 December 2023, made it better still: filters in the admin can now show facet counts, so a manager sees at a glance how many records sit behind each filter value2.

It is worth being precise about what the admin is for, because the Django documentation is. It recommends the admin as an internal management tool for the organisation that runs the site, and says it is not intended as the basis for your whole front end1. That is the half life in action. On day one the admin is a back office for free. As the business grows, the managers' daily screens usually become custom views designed around their real tasks, and the admin retreats to what it is superb at: a trusted place for staff to inspect and fix data.

Rails has no built in admin. It has generators: bin/rails generate scaffold creates the model, the database migration, the controller, the routes, the views and the tests for a resource in one command3. Scaffolds are a starting point you then edit, not a finished back office. For a generated admin, Rails teams add a gem (a Ruby package), such as Administrate, ActiveAdmin or Avo. They work well, but they are an extra dependency with their own conventions, and the Django admin is part of the framework itself, maintained and secured with it.

Example: Cogwell's managers get a job card screen in an afternoon

In Django, Priya first describes a job card as a model. Note the status values, which the whole series uses:

# repairs/models.py
from django.db import models


class JobCard(models.Model):
    class Status(models.TextChoices):
        WAITING = "waiting", "Waiting"
        IN_REPAIR = "in_repair", "In repair"
        READY = "ready", "Ready"
        COLLECTED = "collected", "Collected"

    booking = models.OneToOneField("bookings.Booking", on_delete=models.PROTECT)
    mechanic = models.ForeignKey("workshops.Mechanic", on_delete=models.PROTECT)
    # Django 5.0 accepts the choices class directly, no ".choices" needed
    status = models.CharField(max_length=20, choices=Status, default=Status.WAITING)
    created_at = models.DateTimeField(auto_now_add=True)

Then she registers it with the admin:

# repairs/admin.py
from django.contrib import admin

from .models import JobCard


@admin.register(JobCard)
class JobCardAdmin(admin.ModelAdmin):
    list_display = ["id", "booking", "mechanic", "status", "created_at"]
    list_filter = ["status", "mechanic__workshop"]  # filter by status and by workshop
    search_fields = ["booking__customer__last_name"]
    show_facets = admin.ShowFacets.ALWAYS  # new in Django 5.0: counts beside each filter

That is the whole job. After python manage.py migrate and a staff login, a manager in any of the six workshops can list every job card, filter by status and workshop, see how many cards sit in "waiting" right now, search by the customer's surname and correct a wrong mechanic. Permissions come from Django's built in users and groups, so Hannah can let a workshop manager edit job cards but not invoices.

The Rails route to the same screen is a scaffold plus a few hours of editing, or an admin gem plus its configuration. Either is perfectly workable. Neither is a single file. For the back office line on Hannah's list, Django has a clear, documented head start.

Where Django shines: Python's data ecosystem, in the same language as the web app

Django is written in Python, and Python is where most of the world's data analysis and machine learning happens. The Stack Overflow Developer Survey 2023 makes the scale visible: of all respondents, 49.28% had used Python in the past year, against 6.23% for Ruby. In the libraries list, NumPy (numerical arrays) stood at 20.25%, pandas (tables of data) at 18.97%, scikit learn (classic machine learning) at 9.43% and PyTorch (deep learning) at 8.75%4. Ruby has numerical libraries too, but nothing with that reach.

The point is not that Python is better at web pages. It is that a Django application can import these libraries directly. A forecast, a recommendation or a classification can run inside the same codebase, against the same models, tested by the same test suite and deployed in the same way as the rest of the application. No second service, no second language, no network call between them.

This is a year two or year three strength. Most products do not need a model on day one. But when they do, and when the data work becomes the product's centre of gravity, it is the strongest argument Django has.

There is a fair counterweight. A Rails application can call a small Python service for its data work, and many do. I call this the satellite pattern: the core application in one language, a small satellite in the other, talking over a narrow interface. It works well when the data work is a side job (a nightly forecast that writes numbers into a table). It works badly when the data work is the product (a pricing engine that runs on every page view), because then the satellite becomes a second core.

Example: the parts forecast, written in pandas

Later, Cogwell wants a demand forecast for its 2,400 spare parts, so the nightly reorder report can suggest quantities rather than just flag low stock. Priya's first, deliberately simple version is a moving average of weekly usage over the last eight weeks:

# parts/forecast.py
import pandas as pd


def weekly_forecast(usages: pd.DataFrame) -> pd.Series:
    """usages has one row per part used: columns part_sku, used_on, quantity."""
    weekly = (
        usages.set_index("used_on")
        .groupby("part_sku")["quantity"]
        .resample("W")  # one row per part per calendar week
        .sum()
    )
    # average of each part's last eight weeks, as next week's expected usage
    return weekly.groupby(level="part_sku").tail(8).groupby(level="part_sku").mean()

In a Django application this function can read straight from the PartUsage table through the ORM (object relational mapper, the layer that turns database rows into Python objects), run inside a scheduled task and write its results back to the Part table. Priya already knows pandas from her data analysis work, so this part of the job costs her almost nothing to learn.

In a Rails application the same function lives in a small Python satellite. It reads a nightly export or the database directly and writes suggested quantities back. For Cogwell, with one nightly report, the satellite is a reasonable shape. If the forecast later grew into the heart of the business, for example dynamic pricing of every repair, it would be an argument for Django in the core.

Where Django shines: content, publishing and APIs

Django grew up in a newsroom. Its own FAQ explains that it came from World Online, the web department of a newspaper in Lawrence, Kansas, where developers often had "only a matter of hours" to take a web application from concept to launch5. It was released as open source in summer 20055. That origin shows in its design: strong models for structured content, a powerful template system, the admin as an editing tool, and built in support for things publishers need, such as sitemaps, syndication feeds and internationalisation.

The content strength has a second pillar: Wagtail, "an open source CMS written in Python and built on the Django web framework"6. A content management system (CMS) gives editors a friendly interface for writing and arranging pages. Wagtail 5.2 is a long term support release6. If your product is mostly pages that editors write, with some application logic around them, Django plus Wagtail is a strong, well trodden route. Rails has CMS engines too, but I know of none with a comparable place in its ecosystem, and I would not pretend otherwise.

For APIs, Django has Django REST framework (DRF), "a powerful and flexible toolkit for building Web APIs"7. Its serializers turn models into JSON and validate incoming data, and its browsable API lets a developer explore every endpoint in a web browser. Rails is also good at APIs: it has an API only mode documented in its guides, and JSON views generated by default8. My judgement: both are productive, DRF's browsable API is a genuine comfort for the developers who consume it, and neither choice will hold a mobile app back.

Example: the mechanics' app needs an API

Later, Cogwell wants a small mobile app for mechanics: see today's job cards, move one to "ready", upload the after photo. That needs a JSON API (application programming interface). In Django with DRF, the read and update part is short:

# repairs/api.py
from rest_framework import serializers, viewsets

from .models import JobCard


class JobCardSerializer(serializers.ModelSerializer):
    class Meta:
        model = JobCard
        fields = ["id", "status", "mechanic", "created_at"]


class JobCardViewSet(viewsets.ModelViewSet):
    serializer_class = JobCardSerializer

    def get_queryset(self):
        # each mechanic sees only their own cards
        return JobCard.objects.filter(mechanic__user=self.request.user)

Registered with a DRF router, this gives list, read, update and delete endpoints, and a browsable page for each. The Rails equivalent is a controller with index, show and update actions and a JSON view, a little more code and equally clear. For Cogwell this need is real but small, and it arrives later. It nudges towards Django, gently.

Data heavy internal tools, science and the public sector: it is the people, not the sector

Django is often called the natural choice for scientific, research and public sector projects. I think that is true for a reason worth stating precisely: those organisations tend to employ people who already write Python. Researchers, analysts and statisticians use it every day. A web tool built in Django can be read, extended and maintained by the people who know the data best.

So the honest version of the rule is not "public sector means Django". It is: if the people around the product already write Python, the cost of learning shrinks and the number of people who can help grows. A ministry staffed with Ruby developers should not pick Django because of a sector label. The third chapter of this series, on the honest learning curve, goes into what that cost really is.

Example: who could help Cogwell with reporting

Cogwell's reporting need is modest: bookings per workshop per week, average repair value (£85), mechanic utilisation, parts margin. Priya could write all of that in pandas tomorrow, in either framework, as a satellite or inside Django. Owen could not, in either. The reporting line therefore says less about the framework than about Priya: whichever framework they choose, she will own reporting. In Django she would own it inside the main codebase. In Rails she would either learn to write it with Active Record (Rails' ORM) or keep it as a Python satellite. Both work. The difference is smaller than the sector folklore suggests.

Where Rails shines: one integrated stack for a small team

The Rails doctrine, written by its creator David Heinemeier Hansson, says Rails' "first love is the making of integrated systems"9. In practice, a new Rails 7.1 application already contains, under one release number, one upgrade guide and one set of conventions:

  • Active Record for the database,
  • Action Mailer for email,
  • Active Storage for file uploads, with image variants,
  • Active Job as one interface for background jobs,
  • Action Cable for WebSockets (a permanent connection the server can push updates through),
  • Action Text for rich text,
  • Turbo and Stimulus (together called Hotwire) for the front end,
  • generators for models, controllers, mailers, jobs and whole scaffolds,
  • and, new in 7.1, a production Dockerfile generated with every application10.

Django's core is also generous: an ORM, email, file storage, forms, authentication, the admin. The difference is at the edges. Django core has no built in background job system and no WebSocket support; those come from well established packages (Celery or similar for jobs, Channels for WebSockets). That is a deliberate design choice, loose coupling, not an omission. But for a small team it means more decisions on day one and more upgrade paths to follow later.

Fairness cuts both ways here. Rails' built in queue is not a production queue either. The Active Job guide says the default adapter runs jobs in process and "any jobs in the queue will be dropped upon restart", and that most production applications need a persistent backend such as Sidekiq or GoodJob11. So both frameworks need one extra choice for jobs. Rails' advantage is that the interface is built in, so swapping the backend later does not touch the job code.

Cogwell needsRails 7.1, built inDjango 5.0, built inDjango, common addition
"Your bike is ready" emailAction Mailerdjango.core.mailnone needed
SMSnone (a provider's gem)none (a provider's package)a provider's package
Before and after photosActive Storage, with variantsFileField and storage backendsa storage package for cloud buckets, an image library
Nightly reorder reportActive Job interface, needs a backendnoneCelery or a similar task queue
Live workshop boardAction Cable and Turbo StreamsnoneChannels, or htmx polling
Back officenone (scaffolds, or an admin gem)the adminnone needed

Example: counting Cogwell's day one decisions

Read the table as a count of decisions Priya and Owen must take before the first feature ships, ignoring SMS, which is equal. In Rails: one (the job backend), plus one for the back office (scaffolds or an admin gem). In Django: one for the job queue, one for live updates (Channels or polling), one for photo storage in the cloud. That is two decisions against three. It is not a large gap, and an experienced Django developer makes those three choices in an hour. For two developers new to both frameworks, each choice is a day of reading, and each is a package to upgrade for the next five years. That is the quiet, cumulative strength of an integrated stack.

Where Rails shines: rich interfaces without a separate JavaScript application

Since Rails 7.0 (December 2021), Hotwire is the default front end for new Rails applications12. Hotwire sends HTML rather than JSON to the browser, so the templates stay on the server13. Turbo makes links and forms feel instant and can stream partial page updates over a WebSocket. Stimulus adds small bits of JavaScript where Turbo is not enough13.

For many products this removes the need for a separate single page application written in React or a similar library, with its own build, its own state and its own API. One codebase, one language for the logic, one team. On the Rails side, the live update path is wired in: a model can broadcast changes, Action Cable carries them, and Turbo applies them to every open page.

Example: the live workshop board in Rails

Each workshop has a board with three columns. When a mechanic moves a job card, every screen showing that workshop's board should update without a reload. The model broadcasts the change:

# app/models/job_card.rb
class JobCard < ApplicationRecord
  belongs_to :booking
  belongs_to :mechanic
  belongs_to :workshop

  enum :status, { waiting: 0, in_repair: 1, ready: 2, collected: 3 }

  after_update_commit :move_on_board

  private

  # Remove the card from its old column on every open board for this
  # workshop, then append it to the column for its new status.
  def move_on_board
    broadcast_remove_to workshop, :board
    broadcast_append_to workshop, :board, target: "column_#{status}"
  end
end

The board page subscribes to that stream and renders one column per status:

<%# app/views/boards/show.html.erb %>
<%= turbo_stream_from @workshop, :board %>

<% %w[waiting in_repair ready].each do |status| %>
  <section id="column_<%= status %>">
    <h2><%= status.humanize %></h2>
    <%= render @workshop.job_cards.where(status: status) %>
  </section>
<% end %>

And each card is a partial whose id lets Turbo find it:

<%# app/views/job_cards/_job_card.html.erb %>
<article id="<%= dom_id(job_card) %>">
  <%= job_card.booking.customer.name %>, <%= job_card.mechanic.name %>
</article>

broadcast_remove_to, broadcast_append_to and turbo_stream_from come from the turbo rails gem that ships with every new Rails 7.1 application14. Action Cable, which carries the messages, is part of Rails15, and the configuration a new application generates uses Redis to pass the messages between servers in production. No JavaScript was written. No API was designed. Owen, coming from React, will recognise the result as a live interface, and Priya can read every line of it.

Example: the same board in Django, and why it is closer than it looks

Django has two honest routes. The full push route is Channels, a project that "takes Django and extends its abilities beyond HTTP"16. It needs an ASGI server, a channel layer (usually Redis), a consumer class and a little JavaScript in the page. It is mature and it works, but it is several moving parts more than the Rails version.

The simple route is polling with htmx, a small JavaScript library that lets HTML attributes fetch and swap fragments of the page. The board asks the server for a fresh copy every five seconds:

<!-- repairs/templates/repairs/board.html -->
<div id="board"
     hx-get="{% url 'repairs:board' workshop.pk %}"
     hx-trigger="every 5s"
     hx-swap="outerHTML">
  {% include "repairs/_columns.html" %}
</div>

Is polling good enough? Do the arithmetic rather than argue about it. Say each of the six workshops has two board screens open (a derived assumption, labelled: one by the counter, one in the repair bay). The load from polling is the number of screens divided by the interval:

r=ntr = \frac{n}{t}

where rr is the request rate in requests per second, nn is the number of open board screens and tt is the polling interval in seconds. Foundations: ratios and rates

With n=6×2=12n = 6 \times 2 = 12 screens and t=5t = 5 seconds, the rate is r=12/5=2.4r = 12 / 5 = 2.4 requests per second.

That is a trivial load for any Django server. The cost of polling is not the server. It is the delay: a card can take up to five seconds to move on another screen. For a repair bay that is fine. For a chat or a trading screen it would not be.

So "live" is a number, not a feature. Ask how many seconds of delay the people using the screen will tolerate. If the answer is five, polling in Django is nearly as simple as Turbo Streams in Rails. If the answer is "instantly, for thousands of viewers", the Rails route stays simple while the Django route needs Channels. Hotwire's advantage is real, and for Cogwell it is smaller than it first looks.

Where Rails shines: online shops and SaaS products

Rails has a long, public record in commerce and in software sold as a service (SaaS). Shopify describes its core monolith as "one of the oldest, largest Rails codebases on the planet", with over 2.8 million lines of Ruby17. Shopify is a hosted platform, not something you install, but it is the clearest evidence that a Rails application can carry commerce at enormous scale.

For a shop you own, the open source route on Rails is Solidus, which describes itself as a complete open source eCommerce platform built with Ruby on Rails, licensed under the BSD 3 clause licence18. Solidus is a Rails engine: it lives inside your Rails application rather than beside it, so your shop, your back office and your custom features share one codebase and one database. It is what I build online shops on Solidus with, so read that recommendation with my disclosure in mind.

Django has commerce frameworks too, such as django oscar, which describes itself as a domain driven eCommerce framework for Django19. The honest comparison is that both ecosystems have a credible open source shop framework, and the Rails one sits beside a larger public body of commerce work.

For SaaS, the strength is the integrated stack from the previous sections: a small team can ship accounts, billing emails, file uploads and live updates without assembling them. Multi tenancy, where one application serves many customer organisations with their data kept apart, is well supported on both sides: acts_as_tenant scopes every query to the current tenant in Rails20, and django tenants gives each tenant its own PostgreSQL schema in Django21. That one is a tie.

Example: if Cogwell also sold parts online

Suppose Hannah later wanted to sell some of the 2,400 spare parts online, to the 9,000 active customers. On Rails, Solidus would add a catalogue, cart, checkout, payments and stock to the same application that already knows the parts and the customers. The Part records could become Solidus products, and the nightly reorder report would see web sales and workshop usage in one place. On Django, django oscar could do the same job inside the Django application. Both are possible. The Rails route has more public examples to learn from. For a business whose centre of gravity was the shop rather than the workshop, I would weigh that heavily.

Known products on each, and what they prove

Both frameworks run some very large products, and both companies said so themselves:

  • GitHub writes that "since the beginning, GitHub.com has been a Ruby on Rails monolith", of nearly two million lines, worked on by more than 1,000 engineers every day22.
  • Shopify, as above, runs one of the largest Rails codebases in existence17.
  • Instagram engineers described at PyCon US 2019 how they maintain and extend their own Django application, about a million lines of code with a thousand endpoints23.
  • Disqus described serving about 8 billion page views a month and 45,000 requests a second with Django handling nearly all its web traffic24.

What do these prove? Only that neither framework has a ceiling you are likely to hit. They do not prove fit. Each of those companies chose its framework when it was small, for reasons of team and timing, and then invested heavily to make it scale. Picking Django because Instagram did is like buying a bike because a Tour de France team rides it: it tells you the frame is capable, not that it fits you.

Example: Cogwell's real load

Cogwell takes about 1,150 repair bookings a week. Saturday morning is the peak: 30% of the week's online bookings arrive between Friday 6pm and Saturday noon, an 18 hour window. The peak rate is

rpeak=0.30×BTr_{\text{peak}} = \frac{0.30 \times B}{T}

where rpeakr_{\text{peak}} is the booking rate in bookings per second during the peak, BB is the number of bookings per week and TT is the length of the peak window in seconds. Foundations: ratios and rates

With B=1,150B = 1{,}150 bookings and T=18×3,600=64,800T = 18 \times 3{,}600 = 64{,}800 seconds, the peak takes 0.30×1,150=3450.30 \times 1{,}150 = 345 bookings, so rpeak=345/64,800≈0.0053r_{\text{peak}} = 345 / 64{,}800 \approx 0.0053 bookings per second.

That is one booking every three minutes or so, at the busiest time of the week. Even if every booking caused 50 page views, neither framework would notice. Scale is not part of Cogwell's decision, and for most businesses reading this, it is not part of theirs. The fourth chapter of this series, on performance, hosting and hiring, looks at where load does start to matter.

Where both are equally good: most business applications

Strip away the admin, the data libraries, Hotwire and the commerce engines, and what is left is the bulk of most business software: records, forms, validations, lists, permissions, emails, reports and invoices. Both frameworks do all of this well, with mature ORMs, migrations, form handling, protection against the common web attacks and solid testing tools. A developer fluent in either will build these parts at roughly the same speed.

This is the part of the map most comparisons leave out, and it is usually the biggest part of the product. For an application whose centre of gravity is "ordinary records", the framework is not the decision. The team is.

Example: invoices with VAT

Cogwell's invoices are a perfect tie. Each invoice adds up the labour (at £45 an hour) and the parts used on a job card, then adds VAT at the UK standard rate of 20%25. In Django that is a model, a method and a template that renders to PDF with a library. In Rails it is a model, a method and a view that renders to PDF with a gem. The VAT logic is the same few lines of arithmetic in Python or Ruby. Nothing in either framework makes it easier or harder. If Priya writes it in Django it will take her about as long as it takes Owen in Rails, once each knows the framework. (This is general information about how the software is built, not tax advice.)

Where neither is the best first choice

Batteries included frameworks are built for request and response: a person asks for a page or submits a form, the server answers. Some products do not have that shape, and it is fairer to say so than to bend either framework around them.

  • Real time multiplayer games and very high fan out messaging. When hundreds of thousands of connections each need a message within milliseconds, runtimes designed for massive concurrency fit better. Discord, for example, explained in 2017 how it built on Elixir and the Erlang virtual machine because it was "the perfect candidate" for a highly concurrent real time system26. Go and Node.js are other common choices.
  • Pure static sites. A brochure site or documentation with no logged in users needs no application server at all. A static site generator such as Hugo, Eleventy or Jekyll (which is written in Ruby, as it happens) builds plain HTML files that any host can serve.
  • A mobile app with no web front end. If the product is a phone app and nobody ever uses a browser, the backend may be little more than authentication, storage and an API. A hosted backend service, or a lean API framework, can be enough. Both Django and Rails can serve such an API well, but their strengths (templates, admin, Hotwire) go unused.

Example: three things Cogwell is not

Cogwell's board updates a dozen screens, not a million, so the first case does not apply. It has logged in customers and staff, so it is not a static site, though its marketing pages could be. And its mechanics' app comes later, on top of a web application that exists first. None of the three exceptions applies, which is exactly why Hannah's question is "Django or Rails" and not something else.

Scoring Cogwell's needs against both

Now the map meets the example. Priya and Owen give each need a weight (how much it matters to the business, totalling 100) and score each framework from 1 to 5 on how much head start it gives for that need. The weights and scores below are invented for the example, labelled as such, and based on the documented strengths above. This is product fit only. It deliberately leaves out the team, hiring, hosting and running costs, which the next four chapters cover before the sixth chapter turns everything into a decision.

Need (example weights and scores)WeightDjangoRails
Online booking with slots1544
Live workshop board1535
Job cards with photos1045
Parts stock and nightly report1044
Email and SMS when ready1044
Back office for managers1553
Invoices with VAT544
Reporting544
Mechanics' app API (later)554
Parts forecast (later)1053

The weighted fit for each framework is a weighted mean:

F=∑iwi si∑iwiF = \frac{\sum_{i} w_i \, s_i}{\sum_{i} w_i}

where FF is the framework's weighted fit on the 1 to 5 scale, wiw_i is the weight of need ii and sis_i is the framework's score for need ii. Foundations: the mean

For Django, the products wisiw_i s_i are 60, 45, 40, 40, 40, 75, 20, 20, 25 and 50, which add up to 415. For Rails they are 60, 75, 50, 40, 40, 45, 20, 20, 20 and 30, which add up to 400. The weights add up to 100, so FDjango=415/100=4.15F_{\text{Django}} = 415 / 100 = 4.15 and FRails=400/100=4.00F_{\text{Rails}} = 400 / 100 = 4.00.

On the whole list, Django edges ahead. Now apply the half life rule and score only the first version, the eight needs Cogwell must ship in six months. Remove the two "later" needs (weights 5 and 10, so the remaining weights add up to 85). Django loses 25 and 50 points, leaving 340, and 340/85=4.00340 / 85 = 4.00. Rails loses 20 and 30 points, leaving 350, and 350/85≈4.12350 / 85 \approx 4.12.

The result flips. For the first version, Rails edges ahead, carried by the live board and the photos. Over the whole roadmap, Django edges ahead, carried by the back office and the forecast.

Grouped bar chart of invented example scores, weight times score for each need. Online booking: Django 60, Rails 60. Live workshop board: Django 45, Rails 75. Job cards with photos: Django 40, Rails 50. Parts stock and nightly report: 40 each. Email and SMS: 40 each. Back office: Django 75, Rails 45. Invoices: 20 each. Reporting: 20 each. Mechanics' app API, later: Django 25, Rails 20. Parts forecast, later: Django 50, Rails 30. Totals: Django 415, Rails 400; first version only: Django 340, Rails 350. Tap or click to enlarge

Example: what the score tells Hannah

Three things. First, the gap is tiny either way: 0.15 points on the whole list, 0.12 on the first version. Product fit alone does not decide Cogwell's case. Second, the direction depends on the horizon, which is the half life rule made visible. Third, the needs that drive the result are few: the live board, the photos, the back office and the forecast. Everything else is a tie.

That tells Hannah where to spend her evaluation time. Not on comparing feature lists, but on building those four contested things in both frameworks and seeing how each feels to Priya and Owen. That is what a short spike (a time boxed experiment with real code) is for, and the sixth chapter shows how Cogwell's turns out.

A flow to find your product's shape

If you want the whole chapter as one sequence of questions, here it is. It finds the centre of gravity first and only then names a framework.

Tap or click to enlarge

Notice where the recommended path ends: with the team. For most products, and for Cogwell, that is the honest answer, which is why the next chapter is about how long each framework really takes to learn.

Example: running Cogwell through the flow

Is Cogwell mainly web pages that answer requests? Yes: bookings, job cards, invoices. Are data, models or editorial content the core? Not yet. The forecast comes later and reporting is modest. Is a live, app like interface the core? Partly: the board matters, but it is one screen among many. So Cogwell lands in the middle box, "mostly records and forms", with a lean towards Rails for the first version and towards Django for the later data work. The flow sends Hannah to her team, exactly as the score did.

For the person paying for this

If you commission software rather than write it, here is how to use this chapter in a conversation with a developer or an agency:

  • Ask what the product's centre of gravity is, in their words. If they cannot say whether it is back office, data, content or interaction, they have not thought about fit, only about what they already know.
  • Ask when each strength pays off. A Django pitch that leads with the admin is leading with a day one strength. A Rails pitch that leads with Hotwire is leading with an interaction strength. Both are valid, if those are your product's needs.
  • Ask how a second language would fit, if you need one. A Rails product with a planned Python satellite for data work is a sensible plan. A Django product with a separate React application for a live interface can be too. Either way, the plan should name it.
  • Do not be impressed by famous logos. GitHub, Shopify, Instagram and Disqus prove that both frameworks scale. They say nothing about your fit.
  • Expect a close call for an ordinary business application. If someone tells you one framework is obviously right for a booking, invoicing and reporting system, ask them why. The documented evidence says it is close.

If you want to go through your own list of needs this way, that is exactly what my free workshop is for, and the first two weeks of work are on me.

My view

The strengths are real and checkable. Django's admin is the best built in back office in any mainstream web framework I know, and Python's data ecosystem has no equal. Rails' integrated stack and Hotwire let a small team build a live, app like product without assembling it from parts, and it has the deeper public track record in commerce. Those are not opinions about taste. They are in the documentation and in the companies' own words.

My judgement is about how to use them. Most products are not at either extreme, so the framework strengths decide less than the comparison posts suggest. I would choose Django without hesitation for a product whose core is data, models or editorial content, or for a team of Python developers. I choose Rails for products whose core is a live interface, an online shop or a SaaS product that a small team must ship and keep shipping, which is why I build web applications on Rails. For everything in between, I would let the people decide: who will build it, who will maintain it, and what they can learn in the time available.

Conclusion

Django shines where the work is in the data, the content or the back office: the automatic admin gives you a back office on day one, Python puts pandas, scikit learn and PyTorch in the same codebase as the web application, and Wagtail and Django REST framework are strong for publishing and APIs. Rails shines where the work is in the interaction and in shipping a whole product with a small team: one integrated stack, Hotwire and Action Cable for live interfaces without a separate JavaScript application, generators, and Solidus for shops you own.

Most business applications sit between those poles, and there the two are equally good. Find your product's centre of gravity, remember that some strengths fade and others arrive late, and score your needs for the horizon you actually care about. For Cogwell Cycles the score is close and flips with the horizon, which sends Hannah to the real question: what can Priya and Owen learn, and how fast? That is the subject of the next chapter.

If you want to find your own product's centre of gravity before you pick a framework, book the free workshop and we will score your list of needs together. The first two weeks of work are on me.

Sources

  1. 1.

    Django Software Foundation, The Django admin site, Django 5.0 documentation, https://docs.djangoproject.com/en/5.0/ref/contrib/admin/

  2. 2.

    Django Software Foundation, Django 5.0 release notes, 4 December 2023, https://docs.djangoproject.com/en/5.0/releases/5.0/

  3. 3.

    Rails Core Team, The Rails Command Line (generators and scaffolds), Ruby on Rails Guides v7.1, https://guides.rubyonrails.org/v7.1/command_line.html

  4. 4.

    Stack Overflow, 2023 Developer Survey: Technology (languages, web frameworks, other frameworks and libraries; all respondents), 2023, https://survey.stackoverflow.co/2023/

  5. 5.

    Django Software Foundation, FAQ: General ("Why does this project exist?", "Who's behind this?"), Django 5.0 documentation, https://docs.djangoproject.com/en/5.0/faq/general/

  6. 6.

    Wagtail, Wagtail 5.2 documentation and release notes (LTS), https://docs.wagtail.org/en/v5.2/

  7. 7.

    Django REST framework project, documentation home page, https://www.django-rest-framework.org/

  8. 8.

    Rails Core Team, Using Rails for API only Applications, Ruby on Rails Guides v7.1, https://guides.rubyonrails.org/v7.1/api_app.html

  9. 9.

    David Heinemeier Hansson, The Rails Doctrine ("Value integrated systems"), rubyonrails.org, https://rubyonrails.org/doctrine

  10. 10.

    Rails Core Team, Rails 7.1: Dockerfiles, BYO Authentication, More Async Queries, and more, Ruby on Rails blog, 5 October 2023, https://rubyonrails.org/2023/10/5/Rails-7-1-0-has-been-released

  11. 11.

    Rails Core Team, Active Job Basics (queuing backends, the default async adapter), Ruby on Rails Guides v7.1, https://guides.rubyonrails.org/v7.1/active_job_basics.html

  12. 12.

    David Heinemeier Hansson, Rails 7.0: Fulfilling a vision, Ruby on Rails blog, 15 December 2021, https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision

  13. 13.

    Hotwire, hotwired.dev home page: HTML over the wire (Turbo and Stimulus), https://hotwired.dev/

  14. 14.

    Hotwire, turbo rails, Turbo::Broadcastable, version 1.5.0 source and documentation comments, https://github.com/hotwired/turbo-rails/blob/v1.5.0/app/models/concerns/turbo/broadcastable.rb

  15. 15.

    Rails Core Team, Action Cable Overview, Ruby on Rails Guides v7.1, https://guides.rubyonrails.org/v7.1/action_cable_overview.html

  16. 16.

    Django Channels documentation, https://channels.readthedocs.io/en/stable/

  17. 17.

    Philip Müller, Under Deconstruction: The State of Shopify's Monolith, Shopify Engineering, 16 September 2020, https://shopify.engineering/shopify-monolith

  18. 18.

    Solidus, solidusio/solidus README and licence (BSD 3 clause), GitHub, https://github.com/solidusio/solidus

  19. 19.

    django oscar project page (a domain driven eCommerce framework for Django), Python Package Index, https://pypi.org/project/django-oscar/

  20. 20.

    acts_as_tenant project, README, GitHub, https://github.com/ErwinM/acts_as_tenant

  21. 21.
  22. 22.

    Adam Hess, Building GitHub with Ruby and Rails, The GitHub Blog, 6 April 2023, https://github.blog/engineering/architecture-optimization/building-github-with-ruby-and-rails/

  23. 23.

    Anirudh Padmarao, Benjamin Woodruff and Carl Meyer, Python @Scale: An Instagram Story, talk description, PyCon US 2019, https://pycon-archive.python.org/2019/schedule/presentation/372

  24. 24.

    Disqus, Scaling Django to 8 Billion Page Views, Disqus blog, 2013, https://blog.disqus.com/scaling-django-to-8-billion-page-views

  25. 25.

    HM Revenue and Customs, VAT rates, GOV.UK, https://www.gov.uk/vat-rates

  26. 26.

    Stanislav Vishnevskiy, How Discord Scaled Elixir to 5,000,000 Concurrent Users, Discord blog, 6 July 2017, https://discord.com/blog/how-discord-scaled-elixir-to-5-000-000-concurrent-users

Shelter

I’m running the London Marathon for Shelter. Sunday 25 April 2027

My personal fundraiser. Shelter, the National Campaign for Homeless People Limited, registered charity 263710 (England and Wales) and SC002327 (Scotland), registered with the Fundraising Regulator.

Donate to Shelter