Free course · 12 lessons · Beginner

Django from Basics to Production

Build web apps and APIs with Django 6.1 and Django REST framework: views and URLs, models and the ORM, relationships without N+1 queries, forms, templates and auto-escaping, users and permissions, DRF serializers, viewsets, permissions and pagination, transactions, testing, and the deployment checklist. Every example is a complete single-file Django project whose real responses are shown.

Start the course

1. Django Fundamentals

Views and URLs, models and the ORM, relationships without N+1 queries, forms, templates and authentication.

  1. Your First Django View — Map URLs to views, return JSON and HTML, and call them with Django's test client, in a single-file Django project.
  2. Models and the ORM — Define models, create and query rows, filter with lookups, Q objects and F expressions, and aggregate.
  3. Relationships and the N+1 Query Problem — Model foreign keys and many-to-many relations, and use select_related and prefetch_related to avoid one query per row.
  4. Forms and Validation — Validate user input with Django forms: field validation, custom clean methods, cross-field checks and error messages.
  5. Templates and Auto-Escaping — Render HTML with Django templates: variables, filters, loops, inheritance, and auto-escaping that prevents XSS.
  6. Users, Login and Permissions — Use Django's auth system: create users with hashed passwords, log in, protect views, and check permissions.

2. APIs with Django REST Framework, and Production

Serializers and viewsets, permissions and pagination, transactions, tests and the deployment checklist.

  1. Serializers: Validation and Representation — Turn models into JSON and validate incoming data with DRF serializers, including field-level and object-level rules.
  2. ViewSets, Routers, Permissions and Pagination — Expose a model as a REST API with a ViewSet and router, restrict access per user, and paginate results.
  3. Transactions and Concurrent Updates — Use transaction.atomic for multi-step writes, F expressions and conditional updates for counters, and on_commit for side effects.
  4. Testing Django Apps — Write fast tests with TestCase, test views through the client, assert query counts, and keep test data in setUpTestData.
  5. The Deployment Checklist — Run Django's deployment checks, fix the settings they flag, and prepare static files, secrets and a production server.

3. Capstone

Design a Django application end to end.

  1. Capstone: An Event Ticketing App in Django — Design a Django and DRF app for selling event tickets: models, API, concurrency, permissions, tests and deployment.

Was this page helpful?