How to choose between Django and Rails: a decision method

TL;DR

Difficulty: Beginner

Nobody can give you the verdict from outside your business, but you can decide properly.

  • Ask six questions in order and stop early if one settles it: what the team knows, what the product is, what you already run, who you can hire, who maintains it, who builds it.
  • Otherwise score both in a weighted matrix, weights fixed first, every score backed by evidence.
  • Check the flip distance: if a one point disagreement can overturn the result, it is a tie.
  • Break a tie by choosing the option whose likely mistake is less costly to undo.
  • A Python team, or data science at the core, means Django, clearly.

The closing chapter of the comparison gives you a method, not a verdict. Six questions in a fixed order, a weighted matrix that keeps the scoring honest, a simple test that tells you whether the matrix decided anything at all, and a tie breaker for when it did not. Worked through for an invented chain of bicycle workshops in Sheffield, with the two cases where the answer flips to Django.

You do not need a verdict, you need a method

This is the last chapter of the comparison. The five before it looked at the two frameworks from every side a business cares about: what each one believes, what each one is good at, how long each takes to learn, how each behaves in production, and what each costs over five years. Now the reader's question is the plain one: "I have to decide. Which framework should my business choose, and how do I make that decision properly?"

The honest answer is that nobody can give you the verdict from outside your business. Not a blog, not a survey, and not me. Django and Ruby on Rails are both mature, both open source, both behind large products, and both perfectly capable of carrying a business application for a decade. Rails 7.1 came out on 5 October 20231. Django 5.0 came out on 4 December 2023, with Django 4.2 as the long term support release, receiving security fixes until April 20262. Neither is going anywhere.

What I can give you is a method. It is short: six questions in a fixed order, a weighted matrix to keep the scoring honest, a test that tells you whether the matrix actually decided anything, and a tie breaker for when it did not. By the end you will be able to run it yourself, in an afternoon, with your own numbers.

One disclosure before we start, because you should know who is talking. I build web applications and online shops on Ruby on Rails. I do not build Django applications for clients. That is a bias, and I will name it again where it matters. The method below is built so that it does not care about my bias, and it says plainly when Django is the better choice.

Example: what Hannah actually has to decide

The example that runs through this whole programme is invented. Cogwell Cycles is a chain of six bicycle repair workshops in Sheffield (cogwellcycles.example), founded by Hannah. It has 38 mechanics, about 1,150 repair bookings a week, 9,000 active customers and 2,400 spare parts in stock. The average repair is £85 and the labour rate is £45 an hour. Saturday morning is the peak: 30% of the week's online bookings arrive between Friday 6pm and Saturday noon.

Hannah wants to replace her spreadsheets and a rented booking widget with her own web application. It has to do online booking with a time slot per mechanic, a live workshop board where job cards move between "waiting", "in repair" and "ready", job cards with before and after photos, parts stock with a nightly reorder report, "your bike is ready" by email and SMS, a back office for managers, invoices with VAT, and reporting. Later she wants a small mobile app for mechanics and a demand forecast for parts.

She has two developers. Priya has four years of Python, mostly data analysis and a little Flask. Owen has three years of JavaScript and TypeScript with React. Neither has used Ruby. The budget for the first version is six months.

Hannah is not a developer. She does not want a lecture on metaprogramming. She wants to know which choice gives her a working application in six months, which one she can still staff and maintain in 2029, and how she will know the decision was made properly rather than by whoever argued loudest. That is the decision this chapter makes, step by step.

Six questions, in a fixed order

Most framework comparisons are a feature checklist. Feature checklists are the wrong tool, for a simple reason: for an ordinary business application, both frameworks tick nearly every box. Django has an object relational mapper (ORM), migrations, forms, authentication, an admin, caching and email. Rails has Active Record, migrations, Action Mailer, Active Storage, Action Cable, caching and Hotwire. A checklist comes out as a draw and teaches you nothing.

What separates the two choices for your business is not the frameworks. It is your situation. So the method asks about your situation, in this order:

  1. What does the team already know? The strongest single factor, by a distance.
  2. What shape is the product? Data and machine learning heavy, content heavy, a SaaS product, a shop, an internal tool.
  3. What does the company already run? Existing systems, existing languages, existing data pipelines.
  4. Who can you hire, where you are? The real market in your city and for remote work in your country.
  5. Who will maintain it in five years? The same people, new hires, or an outside developer.
  6. Do you build in house, or buy from a developer or agency? This changes who the "team" in question one is.

The order matters because the early questions can end the decision on their own. If your whole team writes Python every day and the product is a machine learning service with a web front, you can stop at question two: choose Django, or another Python framework. If your company runs a Rails monolith already and the new product sits next to it, question three usually ends it. Only when the early questions do not settle things do you need the full matrix.

Tap or click to enlarge

Example: Cogwell runs the first two questions

Hannah writes down the first year's features (the list above). Then question one: does most of the team already ship in one of the two? No. Priya knows Python, which is a real head start for Django, but she has never built a Django application. Owen knows neither Python web development nor Ruby. The team is split, and nobody is fluent in either framework. Question one does not end it.

Question two: is data science the core of the product? No. The core is booking, a live board, photos and notifications. The parts forecast is real, but it is a later feature for one corner of the business, not the product itself. Question two does not end it either.

So Cogwell is on the long path through the flow chart: the matrix, and very possibly the spike and the tie breaker. That is not bad luck. It is the normal case for a small team that is genuinely free to choose.

Question one: what the team already knows

The team's existing knowledge outweighs everything else because it is where most of the money goes. A framework does not cost anything. People's months do. In the chapter on the honest learning curve I described the learning curve as three curves on top of each other: the language, the framework, and the ecosystem around it (testing, deployment, the front end). A team that already knows all three for one framework starts at full speed. A team that knows none of them pays for all three, on the client's clock.

Two details make this question sharper than "who knows what".

First, count fluency, not familiarity. A developer who did the Django tutorial once is not a Django developer. A developer who has shipped and maintained a Rails application through an upgrade is. Ask: who in the team has taken an application in this framework to production and kept it running for a year?

Second, count the language and the framework separately. Python is far more widely used than Ruby. In the Stack Overflow Developer Survey 2023, 49.28% of all respondents said they had done extensive development work in Python in the past year, against 6.23% for Ruby3. That is a real advantage for Django when the team knows Python. But knowing Python from data analysis is not the same as knowing Django. Priya will still have to learn URL configuration, the ORM's query semantics, class based views and the template language. The language transfers. The framework does not.

Example: scoring Cogwell's team

After the spike (more on that below), Priya and Owen score the team question together, on a scale from 1 (we would be learning everything) to 5 (we ship in this every day).

  • Django gets 4. Priya's Python carries real weight. She reads Python fluently, knows the packaging tools and the testing habits, and was productive in the Django spike from the first day. Owen was learning a new language either way.
  • Rails gets 3. Both had to learn Ruby. Both found it readable, and the spike showed they could work in it, but neither is fluent after two weeks.

That is a one point gap in Django's favour on the heaviest question. It is a fair score, and it is why Django is a serious candidate for Cogwell, not a token one.

Question two: what shape the product is

The second question is the one the chapter on where each framework shines answered in detail. In short, and keeping it fair to both:

  • Data and machine learning at the core: Django. The web application and the models live in the same language, next to pandas, NumPy and scikit learn. That removes a whole boundary.
  • Content heavy and editorial: Django has a strong history here (it came out of a newsroom), with Wagtail, an open source content management system built on Django4, on top. Rails has good options too, but this is home ground for Django.
  • Internal tools and back offices: Django's admin gives you a working back office on day one. The Django documentation is precise about its limits: it describes the admin's recommended use as an organisation's internal management tool, not the base for your whole front end5.
  • A SaaS product or a rich interactive application, built by a small team: Rails. Its doctrine says so in as many words: "value integrated systems"6. Active Record, Action Mailer, Active Storage, Action Cable and Hotwire are one stack, designed to be held in one head. A live page that updates itself is a few lines with Turbo Streams, because turbo rails broadcasts model changes over Action Cable and renders them through Active Job7.
  • An online shop: both have open source options. Solidus is an open source eCommerce platform built with Ruby on Rails8. On the Python side, Django Oscar describes itself as domain driven eCommerce for Django9. Here the shop platform decides more than the framework under it.
  • An ordinary business application (forms, lists, records, permissions, reports): either. This is most applications, and here the product shape barely moves the decision.

Example: scoring Cogwell's product shape

Cogwell's core is booking, the live workshop board, photos and notifications. Priya and Owen built booking and the board in both frameworks during the spike, so they score from what they saw, not from what they read.

  • Rails gets 5. The live board was a model broadcast and a turbo_stream_from tag in the view. Photos went through Active Storage, email through Action Mailer, and the slow work through Active Job. All of it was in the box.
  • Django gets 4. Booking was quick and clean. The board worked with htmx polling every few seconds, which is perfectly acceptable for a workshop. A true push update needs Django Channels, a separate project built on the asynchronous server gateway interface (ASGI) that extends Django beyond HTTP to WebSockets10. It works well. It is one more piece to set up and learn.

They also score the back office separately, because it is a different kind of work.

  • Django gets 5. The admin gave managers a usable view of bookings, mechanics and parts within a day.
  • Rails gets 3. Rails has no built in admin. A back office means generated scaffolds, a gem, or hand built screens. All are fine. None is free.

Questions three and four: what you already run, and who you can hire

Question three looks at the company you already are. If there is an existing Rails application, a new Rails product can share people, code, deployment and habits. If the company's data team works in Python every day, a Django application can share their libraries and their skills. If there is nothing, as at Cogwell, question three mostly asks about the future: what will this system need to talk to, and in which language will that be written?

Question four looks at the market. The chapter on production, hosting and hiring went through it per country. The global picture from the 2023 survey is clear: among professional developers, 10.88% reported working with Django and 6.15% with Ruby on Rails3. That is a little under two to one in Django's favour. Two warnings come with that number. The survey is self selected and global, so it says little about your city. And the size of the pool is not the whole story: what you need is people who have built and maintained a product like yours, and that pool is small for both frameworks in any one city.

The only local evidence worth having is the evidence you collect yourself, on a stated date, with a stated method: search two or three job boards for each framework in your area and for remote roles in your country, write down the counts and the date, and ask a local recruiter how long their last hire took. Then treat the numbers as a snapshot, because that is what they are.

Example: scoring the existing systems and the hiring market

Cogwell has no existing software worth keeping. What it does have is a future need: the demand forecast for parts. Forecasting is data science work, and data science today mostly happens in Python. So:

  • Django gets 5 on "existing systems and the later forecast": the forecast can live inside the same project, in the same language.
  • Rails gets 2: the forecast will need a second language somewhere, and a boundary to look after.

This criterion matters, but not much yet. The forecast is a year away and touches one part of the business.

On hiring, Hannah expects to add one developer in the second year. Priya checks a few job boards for Sheffield and remote UK roles and writes the counts down with the date. Python roles far outnumber Ruby roles, but roles that name Django specifically and roles that name Rails specifically are both a handful in South Yorkshire. Most of the hire will be remote either way. Priya and Owen score both 3: the national survey favours Django, the local market for experienced product developers is thin for both, and they are hiring for one person, not ten.

A senior Django developer might push back and say Django deserves a 4 here. That is a fair challenge. Hold on to it: the section on false precision shows exactly what happens to the result if they are right.

Questions five and six: who keeps it alive, and who builds it

Question five is the one people skip. An application is not finished when it launches. The chapter on five years of upgrades, maintenance and total cost showed that most of the cost comes after launch. Django publishes a feature release roughly every eight months, and certain releases are designated long term support (LTS), with security and data loss fixes for typically three years11. Rails publishes a maintenance policy and moves quickly between minor versions. Both are well run. Neither will maintain your application for you.

So the question is about people. Will the same developers still be there? If not, who takes over, and how easily can they find their way in? Here the two philosophies, explored in the first chapter on two answers to the same question, show up as a practical difference. Rails' conventions mean a new Rails developer knows where things are in any Rails application. Django's explicitness means a new Django developer can read where things are, because the wiring is written down. Both make handover workable. Which suits you depends on the people more than on the framework.

Question six changes who "the team" is. If you buy the application from an outside developer or an agency, their skills become question one, and your own team's skills become a question about the future: who will take it over if the relationship ends? A Django shop will propose Django and a Rails developer will propose Rails, and both will be sincere. That is exactly why the method has to run on your side of the table.

Example: Cogwell's answers to questions five and six

Cogwell builds in house, with Priya and Owen. Hannah wants them to stay, and she also wants the application to survive if one of them leaves. Both frameworks have a predictable release rhythm and a healthy ecosystem, and both developers will be equally new to either codebase in five years' time. They score five year maintenance 4 for both.

The weighted decision matrix

Now the questions are answered, the matrix turns the answers into one comparable number per option. A weighted decision matrix has three parts: criteria (what matters), weights (how much each matters, adding up to 100%), and scores (how well each option does on each criterion, here from 1 to 5).

The total for each option is a weighted average of its scores:

Sf=∑i=1nwi sf,iwith∑i=1nwi=1S_f = \sum_{i=1}^{n} w_i \, s_{f,i} \qquad \text{with} \qquad \sum_{i=1}^{n} w_i = 1

where SfS_f is the total score of framework ff (here Rails or Django), nn is the number of criteria, wiw_i is the weight of criterion ii as a fraction (25% is 0.250.25), and sf,is_{f,i} is the score of framework ff on criterion ii, from 1 to 5. Because the weights add up to 1, the total stays on the same 1 to 5 scale as the scores. Foundations: the mean

Three rules make the matrix honest. Each one exists because of a known way that group decisions go wrong.

  • Set the weights before anyone scores. If the weights are set after the scores are known, people quietly adjust them until their favourite wins. Write them down first, and have the person paying sign them off.
  • Score each criterion separately and independently, then compare. Daniel Kahneman, Olivier Sibony and Cass Sunstein, in their book "Noise" (2021), describe this as the core of what they call the mediating assessments protocol: break the decision into separate assessments, make each one independently, and only then form the overall judgement12. In practice: each developer scores alone, then they talk about the gaps.
  • Write one sentence of evidence next to every score. "The live board took one day in Rails" is evidence. "Rails feels nicer" is not. A score without a sentence is the first one to challenge.

Example: the matrix Hannah signs off

Hannah sets the weights with Priya and Owen before the spike ends. Team knowledge and getting the first version done in six months get the most weight, because the budget is fixed and the team is small. The core product gets the next most. Hiring matters because of the second year hire. The back office, the later forecast and five year maintenance get 5% each: they matter, but they do not separate the options much at Cogwell's size.

The criterion "first version in six months" is scored from the spike: how far each framework got with the core in the same time, with the same two people. In the Rails spike, booking, the board with push updates, photos and the "ready" email worked end to end. In the Django spike, booking and the admin were done and the board refreshed by polling, but photos and notifications were still open. The developers score Rails 5 and Django 3 on this criterion, and note that part of the gap is the integrated stack and part of it may be the order in which they happened to build things.

CriterionWeightRails scoreDjango scoreRails weightedDjango weighted
What the team already knows25%340.751.00
Product fit for the core (booking, live board, photos, notifications)20%541.000.80
First version in six months with two developers25%531.250.75
Back office for managers5%350.150.25
Existing systems and the later parts forecast5%250.100.25
Hiring market, Sheffield and remote UK15%330.450.45
Five year maintenance5%440.200.20
Total100%3.903.70

Worked through for Rails: SRails=0.25×3+0.20×5+0.25×5+0.05×3+0.05×2+0.15×3+0.05×4=3.90S_{\text{Rails}} = 0.25 \times 3 + 0.20 \times 5 + 0.25 \times 5 + 0.05 \times 3 + 0.05 \times 2 + 0.15 \times 3 + 0.05 \times 4 = 3.90. For Django: SDjango=0.25×4+0.20×4+0.25×3+0.05×5+0.05×5+0.15×3+0.05×4=3.70S_{\text{Django}} = 0.25 \times 4 + 0.20 \times 4 + 0.25 \times 3 + 0.05 \times 5 + 0.05 \times 5 + 0.15 \times 3 + 0.05 \times 4 = 3.70.

Grouped bar chart of each criterion's weighted contribution to the total, for Rails and Django. Team knowledge: Rails 0.75, Django 1.00. Product fit for the core: Rails 1.00, Django 0.80. First version in six months: Rails 1.25, Django 0.75. Back office: Rails 0.15, Django 0.25. Existing systems and forecast: Rails 0.10, Django 0.25. Hiring: both 0.45. Five year maintenance: both 0.20. Totals: Rails 3.90, Django 3.70. Tap or click to enlarge

Rails 3.9, Django 3.7. Rails is ahead. The chart shows where the lead comes from: almost entirely from one bar, the first version in six months. Django wins on the team, the back office and the forecast. Most teams would stop here, announce "Rails wins", and move on. That would be a mistake, and the next section explains why.

The trap of false precision: a 0.2 lead is not a result yet

A matrix produces a number with two decimal places. The inputs do not deserve two decimal places. Every score is a judgement, made by a person, after two weeks. Two competent developers can easily disagree by one point on any criterion. A weight of 25% could just as defensibly be 20%. The output looks precise because arithmetic is precise, not because the judgement was.

So the useful question is not "who won?". It is "how much would have to change for the other one to win?". I call that the flip distance, and I find it the single most useful number a decision matrix can produce. It is not a standard term. It is a simple sensitivity check, and it fits on one line.

First, the margin between the two options:

Δ=SRails−SDjango=∑i=1nwi(sRails,i−sDjango,i)\Delta = S_{\text{Rails}} - S_{\text{Django}} = \sum_{i=1}^{n} w_i \left( s_{\text{Rails},i} - s_{\text{Django},i} \right)

where Δ\Delta is the margin (positive means Rails leads), and wiw_i, sRails,is_{\text{Rails},i} and sDjango,is_{\text{Django},i} are the weights and scores from the matrix. Foundations: the mean

Then, for each criterion, the flip distance:

di=Δwid_i = \frac{\Delta}{w_i}

where did_i is the number of score points that one score on criterion ii would have to move (Rails down, or Django up) to cancel the margin. A flip distance of 1 or less means a single, ordinary one point disagreement on that criterion overturns the result. A flip distance above 4 means no change on that criterion alone can overturn it, because a 1 to 5 scale cannot move by more than 4. Foundations: ratios and rates

My rule of thumb: if any criterion with a flip distance of 1 or less has a score that the team could honestly argue about, the matrix has told you "tie", not "winner". That is not a failure of the method. It is the method working. It has told you that, on the things you can measure, the two options are equally good for you, and that the decision has to be made on something else.

Example: one point on the spike flips Cogwell's result

Cogwell's margin is Δ=3.90−3.70=0.20\Delta = 3.90 - 3.70 = 0.20. The flip distance for each criterion:

CriterionWeightFlip distance di=0.20/wid_i = 0.20 / w_iWhat it means
What the team already knows25%0.8 pointsDjango at 5, or Rails at 2, flips it
Product fit for the core20%1.0 pointDjango at 5 ties it
First version in six months25%0.8 pointsDjango at 4 flips it
Back office5%4.0 pointsCannot flip it alone
Existing systems and forecast5%4.0 pointsCannot flip it alone
Hiring market15%1.33 pointsDjango at 4 does not quite flip it (Rails leads by 0.05), but it nearly does
Five year maintenance5%4.0 pointsCannot flip it alone
Bar chart of how many score points one score would have to move to overturn Rails' 0.20 lead. Team knowledge 0.8, product fit for the core 1.0, first version in six months 0.8, hiring 1.33, back office 4.0, existing systems and forecast 4.0, five year maintenance 4.0. Anything at 1 or below is within an ordinary disagreement. Tap or click to enlarge

Now look at the "first version in six months" criterion. Its flip distance is 0.8. The developers themselves wrote, next to the score, that part of the gap may come from the order in which they built things. If Django's score there were 4 instead of 3, Django would total 3.95 and Rails 3.90. Remember the senior Django developer who wanted a 4 on hiring: that alone brings Django to 3.85, five hundredths behind. Both changes are within an honest argument.

So the honest reading of Cogwell's matrix is: a tie, with a slight lean to Rails that rests on one spike. That is a perfectly good result. It means the decision now moves to the tie breaker, and it means nobody at Cogwell has to pretend that 3.9 against 3.7 settled anything by itself.

A short script makes this repeatable. Run it with your own criteria, and change a score to see what moves.

# decision_matrix.py: weighted scores and flip distance (Python 3.12)
criteria = {
    # name: (weight, rails_score, django_score)
    "team knowledge":          (0.25, 3, 4),
    "core product fit":        (0.20, 5, 4),
    "first version in 6 mo":   (0.25, 5, 3),
    "back office":             (0.05, 3, 5),
    "systems and forecast":    (0.05, 2, 5),
    "hiring market":           (0.15, 3, 3),
    "five year maintenance":   (0.05, 4, 4),
}

assert abs(sum(w for w, _, _ in criteria.values()) - 1) < 1e-9, "weights must add up to 1"

rails = sum(w * r for w, r, _ in criteria.values())
django = sum(w * d for w, _, d in criteria.values())
margin = rails - django
print(f"Rails {rails:.2f}  Django {django:.2f}  margin {margin:+.2f}")

for name, (w, _, _) in criteria.items():
    flip = abs(margin) / w
    note = "argue about this one" if flip <= 1 else ""
    print(f"{name:<24} flip distance {flip:4.2f} {note}")

It prints the two totals, the margin, and every criterion whose score is close enough to argue about. That last list is the agenda for the meeting where you make the decision.

When the result flips: the two cases that change everything

A method you can trust should tell you clearly when the other answer is right. For Cogwell, two changes in the situation would flip the result, and neither is subtle.

A team of Python developers only. Suppose Priya and Owen were both experienced Python developers with Django in production behind them. The team criterion would move to Rails 2 (learning a new language and a new framework at once) and Django 5. On the same weights, Rails drops to 3.65 and Django rises to 3.95. The flip distance on that criterion was 0.8. This change moves it by three points. That is not a close call any more. The six month budget cannot afford a language change for the whole team, and no live board is worth that.

A product where data science is the core. Suppose Cogwell were not a workshop chain but a company selling parts demand forecasts to workshops, with a web front end on top of the models. The criteria are the same, but the weights move: the forecast becomes the product. Weights of 25% team, 10% core web features, 15% first version, 5% back office, 30% forecast and data, 10% hiring and 5% maintenance give Rails 3.25 and Django 4.10. Here the web application and the models belong in the same language, and Django is the clear choice.

Grouped bar chart of the matrix totals for Rails and Django in four situations. Cogwell as scored: Rails 3.90, Django 3.70. Django one point higher on the spike: Rails 3.90, Django 3.95. A team of Python developers only: Rails 3.65, Django 3.95. Data science as the core product: Rails 3.25, Django 4.10. Tap or click to enlarge

Example: reading the four bars

The first two bars are the same company with one judgement changed: a tie in all but name. The last two bars are different companies: clear wins for Django, because the situation changed, not the scoring. That is the shape you want to recognise in your own matrix. If the result swings on a single judgement, you have a tie. If it swings only when the facts of the business change, you have a decision.

The tie breaker: choose the mistake that is less costly to undo

When the matrix says "tie", most teams fall back on taste. There is a better question, and it comes from thinking about being wrong rather than about being right: if we choose this and it turns out to be the wrong choice, what does it cost to correct?

Every option has its own way of being wrong, and those ways do not cost the same. Write down, for each option, the most likely way it disappoints you, and what you would do about it. Then choose the option whose likely failure is less costly to repair.

Example: what Cogwell decides

Priya and Owen write down the most likely regret for each choice.

If Cogwell chooses Django and it was the wrong call, the likely reason is the one the spike hinted at: the first version takes longer than six months, because the live board, photos and notifications need more pieces wired together than they planned. The repair is time: a later launch, a few more months of the rented booking widget, and a team under pressure in its first year. Time is the one thing the budget has fixed.

If Cogwell chooses Rails and it was the wrong call, the likely reason is the parts forecast: a year from now, the forecasting work wants Python, and the Rails application cannot simply import scikit learn. The repair is a small Python service beside the Rails application, with a clear boundary (the next section shows exactly how). That is a contained piece of work on one feature, at a time when the first version is already live and earning.

The first mistake hits the whole product at its most fragile moment. The second hits one feature, later, when there is room for it. So Cogwell chooses Rails for the product, and plans a small Python service for the parts forecast. Priya's Python is not wasted: she will own that service.

Note what decided it. Not the 0.2 points. The matrix showed the options were level on everything measurable. The tie breaker chose between two kinds of risk, and Hannah, who pays, could follow every step of it.

Mixing both: a Rails product with a Python data service

"Use both" sounds like the diplomatic answer, and done carelessly it is the expensive one. Two languages mean two dependency trees, two upgrade cycles, two sets of tests and two ways to deploy. The Rails Doctrine's case for integrated systems is a warning against splitting too early6. Martin Fowler made the same argument from the other direction in 2015: start with a monolith, because good service boundaries are hard to find before the system exists13.

So a second service is justified only when the boundary is genuinely clean. Melvin Conway observed in 1968 that organisations which design systems end up producing designs that copy their own communication structures14. Use that on purpose: draw the boundary where the people and the work already divide. At Cogwell, the forecast is one person's job, runs once a night, and needs history rather than live data. That is a natural boundary.

Four rules keep it clean:

  • One owner per table. The Rails application owns every business table: bookings, job cards, parts, part usages. The Python service owns the rows of exactly one table, the forecasts. Neither writes to the other's tables.
  • Batch, not in the request path. The service runs on a schedule and writes results. No customer request ever waits for Python. If the service fails one night, the application keeps working with yesterday's forecast.
  • A written contract. The shape of the forecast table (columns, types, meaning) is written down as a migration in the Rails application and tested on both sides. Changing it is a planned change, not a surprise.
  • Read only from the Rails side. The Rails application treats forecast records as read only, so nobody accidentally edits them in the back office.

Example: Cogwell's nightly parts forecast

The Python service reads a year of part usage, computes a simple forecast per part for the next four weeks, and writes it to its own table. The first version can be modest, a moving average, and grow into a proper model later. The sketch below uses pandas (read_sql and to_sql)15 and SQLAlchemy to talk to the same PostgreSQL database, with a database user that can read the business tables and write only to part_forecasts.

# forecast/nightly.py: runs once a night, after the reorder report (Python 3.12)
import os
import pandas as pd
from sqlalchemy import create_engine, text

engine = create_engine(os.environ["FORECAST_DATABASE_URL"])

# Weekly usage per part over the last 52 weeks, read from the Rails owned tables
usage = pd.read_sql(
    """
    SELECT part_id,
           date_trunc('week', created_at) AS week,
           SUM(quantity) AS used
    FROM part_usages
    WHERE created_at >= now() - interval '52 weeks'
    GROUP BY part_id, week
    """,
    engine,
)

# First version: the average of the last eight weeks, per part, for the next four weeks
recent = usage.sort_values("week").groupby("part_id").tail(8)
forecast = (
    recent.groupby("part_id")["used"].mean().mul(4).round().astype(int)
    .rename("expected_next_4_weeks").reset_index()
)
forecast["computed_at"] = pd.Timestamp.now(tz="UTC")

# Swap last night's rows for tonight's in one transaction; Rails only ever reads them
with engine.begin() as conn:
    conn.execute(text("DELETE FROM part_forecasts"))
    forecast.to_sql("part_forecasts", conn, if_exists="append", index=False)

On the Rails side, the forecast is a plain model that refuses to be written. Active Record calls readonly? before every save, and a record that answers true cannot be saved16.

# app/models/part_forecast.rb (Rails 7.1)
class PartForecast < ApplicationRecord
  belongs_to :part

  # Written only by the nightly Python service, never by this application
  def readonly? = true
end
# app/models/part.rb: the reorder report can now use the forecast
class Part < ApplicationRecord
  has_one :part_forecast

  def needs_reorder?
    expected = part_forecast&.expected_next_4_weeks || 0
    stock_on_hand < expected + minimum_stock
  end
end

That is the whole boundary: one table, one direction, one schedule. The delete and the insert run in one database transaction, so the reorder report never reads a half written forecast. If the forecast becomes a real model later, nothing on the Rails side changes. A production version would add tests on both sides of the contract and an alert when the forecast is more than a day old. The point of the sketch is the shape, not the maths. (The columns stock_on_hand and minimum_stock are part of the invented example's parts table.)

When the choice barely matters, and when it matters a lot

After all this method, a calming fact: for many businesses, the choice matters much less than the debate around it suggests. Both frameworks can carry an ordinary business application for a decade. What decides whether that application is healthy in five years is how it is built: tests, upgrades, clear code, a sensible data model. A well built Django application beats a neglected Rails application, and the other way round, every time.

The choice matters a lot in a few clear situations.

SituationDoes the choice matter?Why
Ordinary business application, team split or new to bothLittleBoth fit; decide by the tie breaker
Team fluent in one of the twoA lotSwitching costs months of the budget
Data science or machine learning is the productA lotWeb and models in one language, so Python
Rich live interface, very small team, tight budgetQuite a lotRails' integrated stack and Hotwire save pieces
Editorial or content heavy siteQuite a lotDjango and Wagtail are strong here
Internal back office for staff onlySomeDjango's admin gives it on day one
Online shopDepends on the shop platformSolidus on Rails, Django Oscar on Django
Company already runs one of the twoA lotShared people, habits and deployment

Example: where Cogwell sits in the table

Cogwell is in the first row: an ordinary business application with a team new to both. The live board puts it partly in the fourth row, which is where Rails' small lead came from. Nothing puts it in a "matters a lot" row for Django. That is why the matrix came out close, and why the tie breaker was the right tool.

Commissioning either from an outside developer

For the person paying for this

If you are buying the application rather than building it with your own team, the method still works, but question six changes the rest. The outside developer's skills become question one. Your own future becomes question five: who takes over if the relationship ends?

You do not need to judge the code to judge the proposal. Ask these questions, and listen for plain answers.

  • Which framework do you propose, and when would you advise the other one? A good developer can name the situations where the other framework is the better choice. If the answer is "never", you are hearing a sales pitch.
  • Who owns the code, the accounts and the data? The answer should be: you. The repository lives in your organisation's account, the hosting and the domain are in your name, and the database is yours. The developer gets access, not ownership.
  • How do I know it works? Ask how the work is tested. Tests written before the code, and plain language scenarios that describe behaviour you can read, are good signs. "We test it by clicking through" is not.
  • What happens at upgrade time? Ask which framework version the application will launch on, how upgrades are handled, and how security fixes reach you. Put it in the contract.
  • Could another developer take this over? Ask how the code is documented and organised, and whether you can see an example of handover notes.
  • What does it cost, and is the price written down? A clear, published price is easier to compare than a quote that appears after three meetings.

Example: Hannah's questions, if she had bought instead

Suppose Hannah had no developers and asked two outside developers for a proposal: one who builds in Django and one who builds in Rails. Both would propose their own framework, and both would be right to. Her matrix would then score the two proposals, not the two frameworks: the developers' track record in applications like hers (question one), the fit with her product (question two), and how easy it would be to find a second developer for that framework in two years (questions four and five). The ownership answer would be a condition, not a criterion: whichever proposal she chooses, the code, the accounts and the data are hers from the first day.

Fair disclosure: I build on Rails, and here is why

I said at the start that I build on Rails, so here is the reasoning, and the limit of it.

I build web applications and online shops on Ruby on Rails, the shops on Solidus. The reason is the one this chapter keeps returning to: Rails is designed so that a small team, or one person, can hold a whole product in their head and carry it from the database to the live page. That fits how I work, as one accountable person who builds, tests and runs the whole thing. I write the tests first and describe behaviour in plain language scenarios with Cucumber, and Rails' integrated testing tools suit that way of working.

That is a reason for me. It is not a reason for you. The method above does not have a slot for "what Georg uses", and it should not.

The other side of the disclosure matters just as much. When your situation points to Django (a Python team, data science at the core, a content heavy product), Django is the better choice, and you should hire a Django developer. I do not build Django applications for clients, so in that case I am the wrong person to build it, and I will say so. The data science side is different: Python is the natural language for that work across the field, and the Rails plus Python boundary above is exactly how I would want such a service to sit next to a Rails product.

My view: for a small team building a SaaS product or an interactive business application, starting free of any framework, Rails gives the most product for the fewest moving parts, and that is why Cogwell's spike leaned that way. For a team that already writes Python, or a product whose heart is data, Django is the better choice without much argument. And for most teams in between, the honest answer is that the choice matters less than how well the application is built and maintained afterwards.

If you want to run this method on your own product, the free workshop is exactly the place for it, and my prices are published in full. If the answer is Rails, I build web applications like the one in this programme.

Example: what the disclosure changes in Cogwell's decision

Nothing, and that is the test. Run Cogwell's matrix again without me in the picture, with any honest developer doing the scoring. The weights come from Hannah's budget and the team. The scores come from the spike. The flip distance shows the tie. The tie breaker compares two concrete regrets. Every step is written down, so anyone can check it, including someone who prefers Django.

What comes next: the same application, built twice

Cogwell's spike produced something unusual: the core of the same application, in both frameworks. The rest of this programme makes use of that, so you can compare like for like.

The next series, Ruby on Rails from the inside, builds Cogwell's application in Rails: how a Rails application is structured, the first decisions when starting one, Active Record, Hotwire for the live board, background jobs, email and files, efficient habits, authentication and security, and how to grow it without it turning into a mess.

The series after it, Django from the inside, builds the Django version of the spike into the same application, with the same models and the same features: projects and apps, the first decisions, the ORM, the admin, templates and htmx or an API, background tasks, authentication and permissions, and growing the project.

The last series, Tests you can trust, covers test driven development, behaviour driven development and end to end tests in both frameworks, on the same application, and finishes with keeping a continuous integration (CI) suite fast and trustworthy.

Conclusion

Choosing between Django and Rails is not a question of which framework is better. Both are excellent. It is a question of which one fits your team, your product and your next five years, and that question has a method.

Ask the six questions in order, and stop early if one of them settles it: what the team knows, what the product is, what you already run, who you can hire, who maintains it, and who builds it. If none settles it, score both in a weighted matrix with the weights fixed first and each score backed by a sentence of evidence. Then check the flip distance. If an ordinary one point disagreement can overturn the result, call it a tie, and break the tie by choosing the option whose most likely mistake is less costly to undo.

At Cogwell, that meant Rails for the product, with a small Python service for the parts forecast later. With a team of Python developers, or with data science at the heart of the product, the same method would have chosen Django, clearly. A method that can give either answer, and says when, is one you can trust with your business.

If you want to run this method on your own product, book the free workshop: we answer the six questions and score the matrix together, and the first two weeks of work are on me.

Sources

  1. 1.

    Rafael França, 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

  2. 2.

    Django Software Foundation, Django 5.0 released, Django weblog, 4 December 2023, https://www.djangoproject.com/weblog/2023/dec/04/django-50-released/

  3. 3.

    Stack Overflow, Stack Overflow Developer Survey 2023, Technology: most popular technologies (programming languages; web frameworks and technologies), 2023, https://survey.stackoverflow.co/2023/#technology-most-popular-technologies

  4. 4.

    Wagtail, Wagtail README (an open source content management system built on Django), GitHub, https://github.com/wagtail/wagtail

  5. 5.

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

  6. 6.

    David Heinemeier Hansson, The Rails Doctrine, rubyonrails.org, 2016, https://rubyonrails.org/doctrine

  7. 7.

    Hotwire, turbo rails (Turbo for Rails, README: broadcasting with Turbo::Broadcastable, Action Cable and Active Job), GitHub, https://github.com/hotwired/turbo-rails

  8. 8.

    Solidus, Solidus README, GitHub, https://github.com/solidusio/solidus

  9. 9.

    Django Oscar, Django Oscar README (domain driven eCommerce for Django), GitHub, https://github.com/django-oscar/django-oscar

  10. 10.

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

  11. 11.

    Django Software Foundation, Django's release process, Django 5.0 documentation, https://docs.djangoproject.com/en/5.0/internals/release-process/

  12. 12.

    Daniel Kahneman, Olivier Sibony and Cass R. Sunstein, Noise: A Flaw in Human Judgment, William Collins (HarperCollins), 2021, ISBN 9780008309039, Open Library record, https://openlibrary.org/works/OL17962180W/Noise

  13. 13.

    Martin Fowler, MonolithFirst, martinfowler.com, 3 June 2015, https://martinfowler.com/bliki/MonolithFirst.html

  14. 14.

    Melvin E. Conway, How Do Committees Invent?, Datamation, April 1968, https://www.melconway.com/Home/Committees_Paper.html

  15. 15.

    pandas development team, pandas.read_sql and pandas.DataFrame.to_sql, pandas documentation, https://pandas.pydata.org/docs/reference/api/pandas.read_sql.html

  16. 16.

    Ruby on Rails API, ActiveRecord::Core, readonly?, Rails 7.1, https://api.rubyonrails.org/v7.1/classes/ActiveRecord/Core.html

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