What Is Django? Python's Batteries-Included Web Framework
A practical introduction to Django — its newsroom origins, the batteries it ships with (ORM, admin, auth, templates), and when to pick it over FastAPI or Flask.
What you'll learn
- ✓What Django is and where it came from
- ✓The batteries Django ships with out of the box
- ✓How the request/response cycle flows through URLs, views, and templates
- ✓When Django is a better fit than FastAPI or Flask
- ✓What a minimal Django project looks like
Prerequisites
- •A basic understanding of Python — see What Is Python?
- •Comfort opening a terminal
Django is the heavyweight champion of Python web frameworks. It has powered Instagram, Pinterest, Disqus, the Washington Post, Mozilla’s developer network, and a long tail of government and enterprise sites. If you need to ship a real web product with users, accounts, an admin panel, and a database — Django is still the most productive way to do it in Python.
This post explains what Django is, where it came from, the batteries that make it special, and how to decide whether it’s the right tool for your project.
If Python is new to you, start there first. If you’re weighing API-only options, the FastAPI introduction is a useful companion read.
Where Django came from
Django was born inside the Lawrence Journal-World, a small newspaper in Lawrence, Kansas, in 2003. The web team — Adrian Holovaty and Simon Willison — needed to ship newsroom features on impossibly tight deadlines: a new database-backed page for an election, a profile of a high-school football player, a searchable city directory. They built a reusable framework on top of Python to keep up.
In 2005 they open-sourced it under the BSD licence, named it after the jazz guitarist Django Reinhardt, and the rest is history. Two decades later it remains under active development by the Django Software Foundation, with a major release every eight months.
The newsroom origin matters. Django was designed to ship content-heavy sites fast, by small teams. Every feature in the box reflects that priority.
What “batteries included” really means
Most modern frameworks (Flask, FastAPI, Express) are deliberately minimal — you pick the database layer, the auth, the templating, the admin. Django takes the opposite stance. The standard install gives you:
- The ORM. A high-level object-relational mapper that lets you describe tables as Python classes and query them without writing SQL. Supports PostgreSQL, MySQL, SQLite, Oracle.
- The admin site. A fully functional CRUD interface for every model in your project, generated automatically. Newsrooms use it as their CMS; engineering teams use it as an internal back-office.
- Authentication. Users, groups, permissions, password hashing, session management, password reset flows — all included.
- Templates. A safe, designer-friendly template language with inheritance, filters, and autoescaping.
- Forms. Server-side form rendering, validation, and CSRF protection.
- Migrations. A version-controlled history of schema changes, generated from your models.
- URL routing. A clean, regex-or-path-based router that maps URLs to view functions.
- Middleware. A hook system for cross-cutting concerns: sessions, auth, security headers, gzip.
- Caching, signals, management commands, internationalisation, testing utilities — and more.
You don’t have to use all of it. But it’s there the moment pip install django finishes.
The request/response cycle
Every Django request follows the same path:
- A URL arrives. The URL configuration (
urls.py) matches it to a view. - The view — a Python function or class — receives a
requestobject. - The view typically queries the ORM for some data.
- The view renders a template (or returns JSON) and returns an
HttpResponse. - Middleware runs on the way in and on the way out, handling sessions, auth, CSRF, etc.
That’s the whole mental model. Once you understand it, you can read any Django codebase.
A minimal Django view
Here is a complete view that reads from the database and renders a page:
# blog/views.py
from django.shortcuts import render
from .models import Post
def post_list(request):
# Fetch the 10 most recent published posts
posts = Post.objects.filter(published=True).order_by("-created_at")[:10]
return render(request, "blog/post_list.html", {"posts": posts})
Wire it to a URL:
# blog/urls.py
from django.urls import path
from . import views
urlpatterns = [
path("", views.post_list, name="post_list"),
]
And render it with a template that extends a site-wide base:
{% extends "base.html" %}
{% block content %}
<h1>Latest posts</h1>
<ul>
{% for post in posts %}
<li><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></li>
{% endfor %}
</ul>
{% endblock %}
That’s the full vertical slice: model → view → template, with a routing layer in between. We cover each in depth in Django Views, URLs, and Templates.
The Django admin in 30 seconds
Register a model:
# blog/admin.py
from django.contrib import admin
from .models import Post
admin.site.register(Post)
Run the server, visit /admin/, log in, and you have a fully working CRUD interface — list view, add form, edit form, delete confirmation, search box. No HTML, no JavaScript, no SQL written.
For internal tools, this alone can save weeks of work. See The Django Admin for the full story.
Django vs FastAPI vs Flask
A short, honest comparison.
Django
Pick Django when you’re building a full web product: HTML pages, user accounts, an admin interface, complex relational data, file uploads, server-rendered forms. The bigger the product surface area, the more Django pays off. The framework has an answer to almost every architectural question, which is a feature for teams shipping under deadline.
FastAPI
Pick FastAPI when you’re building a pure API consumed by a separate frontend (React, mobile, another service). It’s async-first, type-driven, and gives you OpenAPI docs for free. It’s also the default for LLM and ML inference services.
Flask
Pick Flask for small, focused services — a webhook receiver, an internal tool with three pages, a quick prototype. Its appeal is its smallness. For anything large, you’ll end up assembling the same pieces Django gives you in the box.
A common pattern at larger companies: Django for the admin and product site, FastAPI for the public API. The two coexist happily and can even share a database.
A first Django project
Install:
pip install django
Create a project and an app:
django-admin startproject mysite
cd mysite
python manage.py startapp blog
Run it:
python manage.py runserver
Open http://127.0.0.1:8000/ and you’ll see Django’s welcome page. That’s a working web server with admin, auth, sessions, and migrations all wired up — before you’ve written a single line of your own code.
The full walkthrough is in Install Django and Start Your First Project.
Try it yourself. Install Django in a virtual environment and run django-admin startproject demo. Inspect the generated demo/settings.py file and count the entries in INSTALLED_APPS. Each one is a Django “app” that ships in the standard install — admin, auth, sessions, messages, staticfiles, and contenttypes. Browse through urls.py and notice how short it is. Run python manage.py runserver and load the welcome page. You haven’t written any code yet, and you already have a working web server.
When Django is the right tool
Strong fits:
- Content-heavy sites — newsrooms, blogs, marketing sites, knowledge bases.
- SaaS products with a database core — billing dashboards, project trackers, CRMs.
- Internal tools — the admin alone makes Django the fastest way to build a back-office.
- Government and enterprise — Django’s stability, security record, and long-term support are widely trusted.
When it’s not the best fit
- Pure JSON APIs at scale. Django REST Framework works, but FastAPI is leaner and more modern.
- Async-heavy workloads. Django gained async support in 4.x, but it isn’t async-first the way FastAPI is.
- Real-time websocket-driven apps. Channels exists, but you’ll be happier with an async-native stack.
- Tiny single-page services. Django’s structure is overkill for a 50-line webhook handler.
What Django is not
- Not a microframework. It’s opinionated and has structure. You will create projects, apps, and configuration files. That structure pays back as projects grow.
- Not a frontend framework. It renders HTML on the server. You can absolutely pair it with React or HTMX, but Django itself is server-side.
- Not slow. The “Django is slow” trope is mostly cargo-culted. Database queries dominate response times in real apps, and Django’s ORM is competitive.
Recap
You now know:
- Django is a batteries-included Python web framework that came out of a newsroom in Kansas
- It ships with an ORM, admin, auth, templates, forms, migrations, and routing — out of the box
- A request flows through URLs → views → ORM → templates, with middleware on the edges
- Pick Django for full web products; pick FastAPI for pure APIs; pick Flask for tiny services
- A minimal project takes three commands to scaffold and seconds to serve
Next steps
Install Django and scaffold your first project in the next post — Install Django and Start Your First Project. After that, we cover Models and the ORM, Views and Templates, and the admin.
Related: What Is Python?, What Is FastAPI?.
Questions or feedback? Email codeloomdevv@gmail.com.