Skip to content

Lesson 48 of 59Other frameworks

Choosing a Framework

Pick between FastAPI, Django and Flask by project type, team, async needs, admin needs and ecosystem, with a decision table you can reuse.

14 min read0/4 questions

You now know three Python web frameworks well enough to build with each. The next question comes up at the start of every project, in design reviews and in interviews: which one should we use? There is no single best framework, only a best fit for a project, a team and a timeline. This lesson gives you a way to make that call quickly and defend it, plus a realistic picture of what teams actually run.

What each one is optimised for

Each framework made a clear bet, and most decisions follow from those bets.

  • Django bets on completeness. ORM, migrations, auth, admin, forms, templates and security defaults ship together and are designed to work together. You trade freedom for speed on data-heavy products.
  • FastAPI bets on typed APIs. Type hints drive validation, serialization and OpenAPI docs, and it is async first on ASGI. You pick the data layer, auth and everything else.
  • Flask bets on minimalism. Routing, requests and templates, then extensions for the rest. Very little magic, easy to read, easy to bend.
What you get before writing any code
  1. Admin, auth, formsDjango only
  2. ORM and migrationsDjango built in; FastAPI and Flask add SQLAlchemy and Alembic
  3. Validation and API docsFastAPI built in; Django adds DRF; Flask adds extensions
  4. Routing, requests, responsesAll three

Every framework handles routing and the request/response cycle. If that is all you need, any of them works, and Flask is the smallest.

1/4

The questions that decide it

1. What are you building? A JSON API for a frontend or mobile app, a server-rendered website, an internal tool, or a small service? APIs point to FastAPI (or Django with DRF). HTML sites with lots of content and forms point to Django. Small single-purpose services are Flask or FastAPI territory.

2. Do non-developers need to manage data? If staff will create, edit and search records, Django's admin is a huge head start. Building that UI yourself on FastAPI is a real project. Many teams run a Django admin purely as an internal tool even when the public API is something else.

3. How much concurrent I/O? If each request waits on other services, streams data, or holds WebSockets open, an async-first ASGI framework helps. FastAPI is built for it. Django supports async views, but its ecosystem and most ORM usage are still largely synchronous. Flask is WSGI: async def views run, but each request still ties up a worker.

4. Who is on the team? A team fluent in Django ships faster in Django than in anything else, and that usually beats theoretical advantages. Hiring matters too: all three are widely known, Django has the deepest pool of experienced developers, and FastAPI is what many newer Python developers learned first.

5. What ecosystem do you need? Django has mature packages for almost every web need: payments, CMS features, multi-tenancy, social auth. FastAPI pairs naturally with the data and ML world (Pydantic everywhere, async clients, model serving). Flask has a long tail of extensions, some well maintained, some not.

Quick check
A startup is building a marketplace. Ops staff must approve sellers, edit listings and issue refunds from day one. The team knows Python but not any framework deeply. What is the strongest default?
Need a nudge? A hint rules out a wrong answer.

A decision table

SituationGood defaultWhy
JSON API for a SPA or mobile app, new teamFastAPITyped models, validation and OpenAPI docs built in
Content site, marketplace or SaaS with lots of CRUDDjangoORM, admin, auth and forms all included
Existing Django app needs an APIDjango + DRFReuse models, auth and permissions
ML model or data service behind an HTTP endpointFastAPIPydantic schemas, async, light footprint
Many slow outbound calls, streaming, WebSocketsFastAPIAsync first on ASGI
Small internal tool or webhook receiverFlask or FastAPIMinimal setup, a few routes
Team already expert in one frameworkThat frameworkFamiliarity beats small technical gains

Notice what is not in the table: raw benchmark speed. For most apps, time goes to the database and other network calls, not the framework. Choosing on a "requests per second" chart is a classic junior mistake.

A quick way to decide
New project: what do we need?New projectwhat do we need?Admin + HTML?: staff, forms, pagesAdmin + HTML?staff, forms, pagesTyped API?: JSON, async, docsTyped API?JSON, async, docsDjango: add DRF for an APIDjangoadd DRF for an APIFastAPI: + SQLAlchemy, AlembicFastAPI+ SQLAlchemy, AlembicFlask: tiny or legacyFlasktiny or legacystaff dataAPI firstyesyesa few routes

First ask whether people other than developers will manage the data, and whether you need server-rendered pages and forms.

1/5
Match the pairs0/4 matched

Match each project to the framework that fits best by default.

Choose an item, then its match on the other side.

Litestar and the rest

Litestar is another modern ASGI framework with a similar typed, async-first style to FastAPI, with more built in around things like DTOs and plugins; worth knowing about, but it has a smaller community. You will also see Starlette (the toolkit FastAPI is built on), Sanic, Quart (an async take on the Flask API) and Pyramid in older codebases. You rarely need to start a new project with them, but none of them should surprise you.

What companies actually run

In practice, all three are everywhere, and many companies run more than one.

  • Django has a long history at scale. Instagram is the famous example. It is common in content sites, marketplaces, fintech back offices and SaaS products that grew from a monolith.
  • Flask powers a huge amount of older APIs, internal tools and dashboards written before FastAPI existed. You are likely to maintain Flask code even if you never start a Flask project.
  • FastAPI has grown fastest in recent years, especially for new microservices, data and ML platforms, and AI products, where Pydantic and async fit naturally. In the Python developer surveys run by the PSF and JetBrains, Django, Flask and FastAPI are consistently the three most used web frameworks.

A very common modern shape is a Django monolith for the core product and admin, plus a few FastAPI services for model serving or high-concurrency work. Mixing is normal. What matters is that each choice has a reason.

Quick check
Which reason for picking a framework is the weakest?
Need a nudge? A hint rules out a wrong answer.

Switching later

Teams rarely rewrite a working app just to change frameworks, and they are usually right. Business logic that lives in plain Python modules (services, domain models, pure functions) moves between frameworks easily. Logic spread through views, serializers and ORM signals does not. Whatever you choose, keep the framework at the edges: routes parse input and return output, and the real work happens in code that does not import the framework. That makes a later move, or adding a second framework next to the first, far cheaper.

The cost over time

The first week is the wrong place to judge a framework. Think about year two.

  • Django keeps its conventions as a project grows, so a new hire is productive quickly. The cost shows up when your product stops looking like Django: heavy async work, unusual data stores, or an API-only product where templates and forms go unused.
  • FastAPI stays small and explicit, but the structure is yours to design. Two FastAPI codebases can look nothing alike. Without agreed patterns for project layout, sessions and settings (the ones this course teaches), a large FastAPI app can drift into inconsistency.
  • Flask has the same freedom with fewer built-in guardrails, plus a dependency on extensions that may be maintained at different paces. Check that an extension is active before you rely on it.

Upgrades matter too. Django has a predictable release cycle with long-term support releases, which suits teams that want to upgrade on a schedule. FastAPI and its main dependencies, Starlette and Pydantic, move faster, so pin versions in your lockfile and read the release notes when you upgrade.

Predict the output

Using the decision table, how many of these situations default to FastAPI?

1. Inference API for an ML model
2. Newsroom CMS with editors
3. Service streaming updates over WebSockets
4. Existing Django app that needs an API
Need a nudge? Hints walk you through it.
Key terms
batteries included
A framework that ships ORM, auth, admin and more together, like Django.
microframework
A framework with a minimal core that you extend with plugins, like Flask.
ASGI
The async Python server interface used by FastAPI, Starlette and Litestar; Django supports it too.
WSGI
The older synchronous server interface used by Flask and traditional Django deployments.
Litestar
A modern async-first ASGI framework in a similar style to FastAPI.
architecture decision record
A short document recording a technical choice, the options and the reasons.