Django
Overview
Django is a high-level Python web framework that encourages rapid development and clean design. It ships with an ORM, admin interface, forms, auth, migrations, and a template engine, making it a strong choice for content-heavy sites and internal tools.
Key concepts
- MTV — Model–Template–View (Django’s structuring of data, presentation, control).
- Apps — Reusable modules installed in a project.
- ORM — Database-agnostic models with migrations.
- Middleware — Request/response pipeline hooks.
- Security defaults — CSRF, XSS helpers, clickjacking protection when configured.
Request handling
Sample: URL + view
# urls.py
from django.urls import path
from . import views
urlpatterns = [
path('api/health/', views.health),
]
# views.py
from django.http import JsonResponse
def health(request):
return JsonResponse({'ok': True})