Skip to content

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