Django โ Web Framework Training
Last reviewed: 2026-05-29
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers at the Lawrence Journal-World, it follows the "batteries-included" philosophy, providing everything needed to build production-ready web applications out of the box.
Overview
Django follows the MTV (Model-Template-View) architectural pattern: - Model โ Database schema and data access (ORM) - Template โ HTML rendering with Django Template Language - View โ Business logic that connects models and templates
Key features: admin interface, ORM, authentication, URL routing, forms, serialization (Django REST Framework), migrations, template engine, security (CSRF, XSS, SQL injection protection).
Training Content
- Django installation and project setup (
django-admin startproject,manage.py) - Models and migrations (
makemigrations,migrate) - Views and URLs (function-based vs class-based views)
- Templates and template inheritance
- Django Admin customization
- Forms and form validation
- Static files and media handling
- Deployment basics (WSGI, Gunicorn, Nginx)
Core Concepts
Project Structure
myproject/
โโโ manage.py # CLI utility
โโโ myproject/
โ โโโ __init__.py
โ โโโ settings.py # Configuration
โ โโโ urls.py # Top-level URL routing
โ โโโ asgi.py # ASGI entry point
โ โโโ wsgi.py # WSGI entry point
โโโ myapp/
โโโ __init__.py
โโโ admin.py # Admin interface config
โโโ apps.py # App configuration
โโโ models.py # Database models
โโโ views.py # HTTP handlers
โโโ urls.py # App-level URL routing
โโโ serializers.py # DRF serialization
โโโ forms.py # Form definitions
โโโ templates/ # HTML templates
Django ORM
from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
email = models.EmailField()
class Book(models.Model):
title = models.CharField(max_length=200)
author = models.ForeignKey(Author, on_delete=models.CASCADE)
published = models.DateField()
URL Routing
# urls.py
from django.urls import path
from . import views
urlpatterns = [
path('books/', views.BookListView.as_view(), name='book-list'),
path('books/<int:pk>/', views.BookDetailView.as_view(), name='book-detail'),
]
Django REST Framework (DRF)
Django REST Framework is the most popular extension for building REST APIs with Django: - Serializers (ModelSerializer for model โ JSON) - ViewSets and ModelViewSets for CRUD views - Routers for automatic URL generation - Authentication (Token, JWT, Session) - Permissions and throttling - Browsable API UI
Migrations
python manage.py makemigrations # Generate migration files
python manage.py migrate # Apply to database
python manage.py sqlmigrate app 0001 # View SQL
python manage.py showmigrations # Show migration status
Deployment
- Gunicorn + Nginx (traditional reverse proxy)
- Daphne or Uvicorn (ASGI for channels)
- Docker containerization
- Platforms: Railway, DigitalOcean App Platform, Heroku, Fly.io
- Environment variables for configuration (
django-environ/python-decouple)
Resources
- Django Documentation
- Django REST Framework Docs
- Django for Beginners by William S. Vincent
- Two Scoops of Django โ Best practices