Django Tutorial
Build database-driven websites in Python with Django — 24 interactive lessons from your first view to a complete, working blog application.
Learn Django from scratch — models, the ORM, views, templates, forms, the admin, authentication and Django REST Framework — free interactive lessons.
Part of the free Django course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
👋 New to Django? Some Python basics are all you need.
Start with Lesson 1 and build a real web app step by step — at your own pace.
Lessons in this course
- Introduction to Django — What Django is, why it powers data-driven sites, and how to install and start a project
- Projects vs Apps — Understand the difference between a Django project and the reusable apps inside it
- Views & URLs — Map URLs to view functions that return HTTP responses
- Templates — Render dynamic HTML with the Django template language and context data
- Static Files — Serve CSS, JavaScript, and images with Django's staticfiles system
- The Django Admin — Get a powerful auto-generated admin interface for your data for free
- Models & Migrations — Define your database schema in Python and evolve it safely with migrations
- The ORM: Queries — Create, read, update, and delete data with Django's QuerySet API
- Relationships (FK, M2M) — Connect models with ForeignKey, ManyToManyField, and OneToOneField
- Forms — Build, render, and validate HTML forms with Django's forms framework
- ModelForms — Generate forms directly from your models to save and update records
- Class-Based Views — Write reusable, object-oriented views and understand the request flow
- Generic Views — Use ListView, DetailView, and the editing views to cut boilerplate
- Template Inheritance — Share a common layout across pages with extends, block, and include
- URL Namespacing — Organise URLs with app namespaces and reverse them by name
- The Messages Framework — Show one-time flash notifications to users after an action
- User Authentication — Log users in and out and protect pages with Django's auth system
- Permissions & Decorators — Restrict access with login_required, permissions, and mixins
- Django REST Framework Intro — Turn your Django models into a JSON API with DRF
- Serializers & ViewSets — Convert models to JSON and build full CRUD APIs with routers
- Signals — React to model events automatically with Django's signal dispatcher
- Middleware — Hook into every request and response with custom middleware
- Testing Django — Write reliable tests for models, views, and forms with Django's test tools
- Migrations Deep Dive — Understand migration files, data migrations, and the migration graph
- Model Fields & Options — Choose the right field types and options (null, blank, choices, unique)
- Model Methods, __str__ & Meta — Add behavior to models with methods, properties, and the Meta class
- QuerySet Deep Dive: Q, F & Lookups — Build powerful queries with field lookups, Q objects, and F expressions
- Aggregation & Annotation — Summarise and group data with Count, Sum, Avg, and annotate()
- Query Performance: select_related & prefetch_related — Kill the N+1 query problem and write fast, efficient ORM code
- Custom Managers & QuerySets — Encapsulate reusable query logic in managers and chainable QuerySets
- Custom Template Tags & Filters — Extend templates with your own filters, simple tags, and inclusion tags
- Checkpoint: Models & the ORM — Combine models, advanced queries, aggregation and managers — then a quiz
- Pagination with Paginator — Split long result lists into pages with Django's Paginator
- The Sessions Framework — Store per-user data across requests with the session framework
- File & Image Uploads — Handle uploads with FileField, ImageField, MEDIA, and request.FILES
- Sending Email — Send plain-text and HTML email with send_mail and templated messages
- The Caching Framework — Speed up your site with per-view, low-level, and fragment caching
- Custom Management Commands — Automate tasks with your own manage.py commands and arguments
- DRF Authentication & Permissions — Protect API endpoints with token auth, permissions, and throttling
- Deployment: WSGI, Static & Settings — Ship to production with DEBUG=False, collectstatic, Gunicorn, and env settings
- Checkpoint: Build a Django REST API — Combine pagination, auth, caching and serializers into a JSON API — then a quiz
- Context Processors — Make variables available in every template automatically
- Custom User Model — Swap in your own user model with AUTH_USER_MODEL and a manager
- Formsets & Inline Formsets — Handle many forms at once, including related-object inlines
- Class-Based View Mixins — Compose views with LoginRequired, permission, and context mixins
- Async Views & ASGI — Write async views and use the async ORM under ASGI
- Real-Time with Django Channels — Add WebSockets with consumers, channel layers, and groups
- Background Tasks with Celery — Run slow work off-request with shared tasks, brokers, and retries
- Checkpoint: Production Django — Combine a custom-user mixin and a background task — then a quiz
- Capstone: A Blog App — Combine every skill into a complete, working blog application
- Internationalization (i18n & l10n) — Translate your app with gettext, {% trans %}, LocaleMiddleware and .po files
- GraphQL APIs with Graphene — Expose a typed GraphQL API with graphene-django types, queries and mutations
- Full-Text Search & Docker Deployment — Postgres SearchVector/SearchRank, GIN indexes, then ship with a Dockerfile + gunicorn
- Static & Media Files on S3 — Serve static and user-uploaded media from S3 with django-storages and a CDN