Learn Django by building one small blog from an empty folder to a deployed app. Every lesson is real code you type and run — models, the admin, routing, views, templates, forms, auth, a REST API, testing, and deployment.
Django is a Python web framework. Be comfortable with Python before starting — the rest you pick up as you build.
Before you start
To follow along on your computer:
Ctrl+`).myblog project grows as you go. With the dev server running, open http://127.0.0.1:8000 to see your work.Set Up Django & Create a Project
Create an isolated virtual environment, install Django, generate your first project, and run the development server — the foundation every later lesson builds on.
Apps & Settings
A Django project is a collection of apps. Create your first app, register it, and learn the settings you actually touch — DEBUG, ALLOWED_HOSTS, INSTALLED_APPS, and time zone.
Models & Migrations
Describe your data as Python classes and let Django build the database. Define fields and relationships, then turn them into tables with makemigrations and migrate.
The ORM — Querying Data
Read and write data in Python instead of SQL. Create, filter, order, update, delete, aggregate, and optimize queries using Django’s object-relational mapper.
The Django Admin
Get a full database management UI for free. Create a superuser, register your models, and customize the list and edit screens to make the admin genuinely useful.
URL Routing
Map URLs to views. Include app URLConfs, capture parts of the path with converters, name your routes, and build URLs in reverse instead of hard-coding them.
Views — Functions & Classes
Turn a request into a response. Write function-based views, handle GET vs POST, then let Django’s class-based generic views do the repetitive work of listing and editing objects.
Templates (DTL)
Build HTML with the Django Template Language — variables, filters, the if and for tags, the static and url tags, template inheritance, and your own custom filters.
Forms & Validation
Collect and validate user input safely. Build forms, generate them from models with ModelForm, add custom validation rules, and protect every POST with CSRF.
Authentication & Authorization
Use Django’s built-in auth system — log users in and out, protect views, check permissions, read the current user, and swap in a custom user model the right way.
Static Files, Middleware & Everyday Tools
Round out a real project — serve CSS and JS, paginate long lists, flash success messages, write custom middleware, and use management commands and the shell.
Building a REST API
Expose your models as a JSON API with Django REST Framework — serializers, API views, ViewSets, and routers — plus where Django Ninja fits in.
Testing & Debugging
Catch bugs before users do. Write tests with TestCase and the test client, run them with pytest, debug with breakpoints and the debug toolbar, add error pages, and configure logging.
Signals, Caching & Background Tasks
Scale a Django app — react to events with signals, speed it up with caching, run slow work in the background with Celery, write async views, and translate the UI.
Deployment & Production Checklist
Take your blog live safely — production settings, secrets from the environment, static files with WhiteNoise, a real WSGI server with Gunicorn, and Django’s deploy checklist.