Single logo
  • Courses
  • Blog
  • About
Join on SkoolJoin on Skool

In this topic

Django
  • Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose
  • Getting Started with Django: Models, Views, Templates, the ORM and the Admin
  • Your First Django Project and App: uv, startproject, startapp and a First View
  • The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built
  • How a Request and a Login Flow Through Django: URLconf, ORM, CSRF, Password Hashes and Sessions
  • Testing a Django Blog with pytest-django: Fixtures, the Test Database and the Client
  • One Blog, Three Frameworks: Routing, Models, Templates and Layout in Django, FastAPI and Flask
  • Building a Blog with an AI Coding Agent: Plan Mode, a Master Prompt and the First Review
  • Handing a Figma Design to an AI Agent: Compare the Files, Then Review the Change
  • Django Models, Migrations and the Admin: From a Post Class to a Real Table
  1. Blog
  2. /
  3. Django
  4. /
  5. Fundamentals

Django, FastAPI or Flask? The Same Blog Feature in Three Shapes, and How to Choose

One small project lists two blog posts three times: as a Django view, a Flask route and a FastAPI endpoint. See each shape with its real output, what each framework includes, and a three-question way to choose.

Chaand Sheikh

·27 November 2026·Updated 28 November 2026Fundamentals

What you will learn

  • Describe how much Django, FastAPI and Flask decide for you
  • Read the same list-posts route written in all three frameworks
  • Explain why Django and Flask answer with a page here and FastAPI with JSON
  • Pick a framework with three questions about what you're building

Before you start

  • Python functions and classes
  • What an HTTP request and response are

Once you know Python, the next step is putting it on the web, and almost everyone asks the same question here: Django, FastAPI or Flask? In this course each of the three tracks builds the same blog. It lists all the posts, shows one post, lets you write a new post and lets you log in to write. Whichever track you take, you end up with the same blog. That's why the choice isn't scary.

Moving into a home

Think about moving into a home.

  • Django is a furnished apartment. You walk in and everything is there: an admin panel, a database layer called the ORM, and login with users. You follow the house rules.
  • Flask is an empty studio with a toolbox. The core is small, so you pick the database tool, you pick the login tool, and you place every piece yourself.
  • FastAPI is a smart workshop with labelled drawers. The labels are type hints, so every drawer says what it holds, and the manual prints itself at /docs. It's built for APIs and async work.

The difference is how much is decided for you. It isn't about which one is better.

One job, three folders

The project for this comparison, S01L01_ThreeShapes, does one blog job three times: list the posts. There's a folder per track, and all three share one template and one data file. Here's posts.py:

POSTS = [
    {"title": "Hello Web"},
    {"title": "Three Tracks"},
]


def load_posts():
    return POSTS

In the full tracks this comes from a database. And the shared template, templates/posts.html:

<ul>{% for post in posts %}<li>{{ post.title }}</li>{% endfor %}</ul>

Each track has a small check.py that sends one request with the framework's test client and prints the answer. The job is the same everywhere; only the shape of the code changes.

The Django shape

In Django the route sits in its own file, urls.py:

from django.urls import path

from views import post_list

urlpatterns = [path("posts/", post_list)]

and the function sits in views.py:

from django.shortcuts import render

from posts import load_posts


def post_list(request):
    posts = load_posts()
    return render(request, "posts.html", {"posts": posts})

path maps /posts/ to post_list. The view takes the request, loads the posts and returns render with the template. In the Django track, the load_posts() line becomes Post.objects.all(), the ORM. Running check.py:

200 text/html; charset=utf-8
<ul><li>Hello Web</li><li>Three Tracks</li></ul>

In Django the route lives in urls.py, and the answer is a page. (More in getting started with Django.)

The Flask shape

Flask keeps it in one file, flask_track/app.py:

from flask import Flask, render_template

from posts import load_posts

app = Flask(__name__, template_folder="../templates")


@app.get("/posts")
def post_list():
    posts = load_posts()
    return render_template("posts.html", posts=posts)

The route, @app.get("/posts"), sits right on top of the function. There's no second file for routes. The function returns render_template with the same template, and check.py prints exactly what Django printed:

200 text/html; charset=utf-8
<ul><li>Hello Web</li><li>Three Tracks</li></ul>

In Flask the route sits on the function, and the answer is again a page. (More in getting started with Flask.)

The FastAPI shape

And fastapi_track/main.py:

from fastapi import FastAPI
from pydantic import BaseModel

from posts import load_posts

app = FastAPI()


class Post(BaseModel):
    title: str


@app.get("/posts")
def post_list() -> list[Post]:
    return load_posts()

First we describe a Post: a Pydantic model with a title that is a string. Then the function says it returns list[Post]. That arrow is a type hint, and FastAPI uses it to check every post on the way out. check.py also asks for /docs:

200 application/json
[{"title":"Hello Web"},{"title":"Three Tracks"}]
/docs 200

Same job, but the answer is data, not a page. And /docs answers 200: nobody wrote those docs, FastAPI built them from the type hints. (More in FastAPI hello world.)

The recorded run used Django 6.1.3, Flask 3.1.3 and FastAPI 0.162.2.

A page or data

posts.py feeds three tracks. Django and Flask answer text/html, a page ready for the browser. FastAPI answers application/json, data ready for another program, a phone app or a frontend. posts.py Django view Flask route FastAPI endpoint text/html: a page ready for the browser to show application/json: data for a program, app or frontend
The posts are the same on both sides. Only the shape of the answer differs.

Django and Flask sent back a page, ready for the browser. FastAPI sent back data, ready for another program, a phone app or a frontend. That is the shape this small project uses; all three can answer either way (the FastAPI track blog, for example, renders HTML pages with Jinja2). The difference between the two answers gets its own article: one request, two answers: page or JSON.

What comes with each one

"Included" means it comes with the framework. "Add" means you add a package, or only part of it is covered.

FeatureDjangoFastAPIFlask
Admin panelincludedadd a packageadd a package
Database layerown ORMusually add SQLAlchemyusually add SQLAlchemy
Page templatesown template languagecan use Jinja2, you add itJinja2 included
Login and usersincludedtoken helpers; you build usersadd a package
Async supportasync views, partly asyncbuilt for itasync views, partly async
Automatic API docsadd a packageat /docsadd a package
How much you chooseleast: decides most for youmany pieces, like the data layermost things

"Add a package" doesn't mean bad. It means one more piece, and each track shows which packages it uses.

A quick decision flow

Three questions. Pages, an admin and users quickly? Django. Mostly an API, AI services or async work? FastAPI. A small app where you want to see every moving part? Flask. 1. Pages, an admin and users, quickly? a whole site, a team that likes shared rules 2. Mostly an API, AI services or async? data in, data out 3. Small app, see every moving part? learn how web apps work underneath Django furnished apartment FastAPI smart workshop Flask studio and toolbox yes yes yes
Start from what you're building, not from hype. You can take a second track later.

Or, as three short stories: "I want a full website with an admin and logins" points to Django. "I want to build APIs and AI services" points to FastAPI. "I want to learn how web apps work underneath" points to Flask. If you're still not sure, any of the three is a good start, because the blog is the same.

What stays the same

Whatever you pick, a lot carries over: Python itself, the blog features (list, read, write, log in), databases with tables, rows and queries, requests and responses, Docker for packaging later, and the use cases later in the course. One note: the AI services later in the course are built with FastAPI, so you'll meet it either way. A second framework is mostly new names for ideas you already know. When you're done with one track, one blog, three frameworks maps your blog onto the other two.

Quick recap

DjangoFastAPIFlask
Picturefurnished apartmentworkshop with labelled drawersstudio with a toolbox
Where the route livesurls.pydecorator on the functiondecorator on the function
Answer in this projectpage, text/htmldata, application/jsonpage, text/html
Pick it forfull sites with admin and usersAPIs, AI services, asyncsmall apps, seeing every part

Try it yourself

Add a third post to POSTS in posts.py and run all three check.py files. Then add a "draft": True key to one post and decide, for each track, where you'd filter it out.

Tried the exercise? Share your answer or ask a question.

The StudyEasy AI Community is free to join, with the lesson files, notebooks and code.

Join free on Skool

Keep going in Django · 1 of 10

Next post
Getting Started with Django: Models, Views, Templates, the ORM and the Admin

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Related posts

Getting Started with Django: Models, Views, Templates, the ORM and the Admin

A tiny Django menu app with one model, one view, one URL, one template and the admin. What each file does, how one request travels through them, and the real output of a run.

Your First Django Project and App: uv, startproject, startapp and a First View

Set up a Django project called blogproject with uv, add an app called blog, write one view that returns Hello blog, give it the empty path and run the server. Every command with its real output.

The Django Project Folder Structure, File by File: Reading a Blog an AI Agent Built

A tour of a finished Django blog: manage.py, the project package, the blog app with its models, views, templates, forms and admin, a custom command, the REST API and Swagger docs, plus the review points check --deploy found.

How a Request and a Login Flow Through Django: URLconf, ORM, CSRF, Password Hashes and Sessions

Follow the home page from URLconf to SQLite and back (8 queries), then a login: the csrftoken, a 403 without it, the pbkdf2 password hash, the django_session row, the sessionid cookie, and a review finding about who may write posts.

On this page

  • Moving into a home
  • One job, three folders
  • The Django shape
  • The Flask shape
  • The FastAPI shape
  • A page or data
  • What comes with each one
  • A quick decision flow
  • What stays the same
  • Quick recap
  • Try it yourself
Community · Free to join
Single logo

StudyEasy AI Community

Hosted onSkool

Learn AI engineering, share what you build, and connect with other learners.

  • Free resources: lesson files, notebooks and code

  • Ask questions and join engineering discussions

  • Meet real people learning and building with AI

Join free on Skool

Related course on Udemy

The Python Architect Masterclass: Full Stack to AI Engineer

Python, Django, FastAPI, React, Docker, AWS, LLMs, RAG, agents and MCP, from first steps to AI engineer.View on Udemy ↗: The Python Architect Masterclass: Full Stack to AI Engineer (paid course, opens in a new tab)

Single logo

Empowering Education, One Course at a Time

About
About usContact us
Legal
Terms of UsePrivacy Policy

© 2026 StudyEasy Organization. All rights reserved.