Django implementation checklist
This checklist provides a technical verification path for transitioning Django applications from development to production environments, focusing on performance, security, and scalability.
Security and Environment Configuration
0/5Disable Debug Mode
criticalSet DEBUG=False in the production settings to prevent the exposure of sensitive tracebacks and environment variables.
Secret Key Externalization
criticalEnsure SECRET_KEY is loaded from an environment variable or a secret manager, and is not hardcoded in the repository.
Secure Cookie Settings
criticalSet SESSION_COOKIE_SECURE=True and CSRF_COOKIE_SECURE=True to ensure cookies are only transmitted over HTTPS.
Host Header Validation
criticalDefine ALLOWED_HOSTS with specific domain names to prevent HTTP Host header attacks.
HSTS Implementation
recommendedSet SECURE_HSTS_SECONDS, SECURE_HSTS_INCLUDE_SUBDOMAINS, and SECURE_HSTS_PRELOAD to enforce SSL at the browser level.
Database and Performance Optimization
0/5Database Connection Pooling
recommendedSet CONN_MAX_AGE to a value (e.g., 60) to persist database connections and reduce overhead on high-traffic sites.
Index Verification
criticalAudit models for db_index=True or Meta.indexes on fields used in filtering and ordering to prevent full table scans.
N+1 Query Audit
recommendedReview views and serializers for missing select_related or prefetch_related calls on foreign key and many-to-many relationships.
Database Migration Dry-Run
criticalVerify that all migrations have been applied and that no pending model changes exist via 'python manage.py makemigrations --check'.
Read-Replica Routing
optionalConfigure a database router if using read-replicas to offload SELECT queries from the primary write database.
API and DRF Standards
0/5Global Throttling Policy
criticalConfigure DEFAULT_THROTTLE_CLASSES and DEFAULT_THROTTLE_RATES in DRF settings to prevent API abuse.
Mandatory Pagination
criticalEnforce DEFAULT_PAGINATION_CLASS for all list views to prevent large database dumps from crashing the application.
CORS Whitelist
criticalConfigure django-cors-headers to only allow requests from trusted frontend origins.
Schema Documentation
recommendedGenerate and verify OpenAPI/Swagger documentation using drf-spectacular or similar tools for consumer integration.
Renderer Optimization
recommendedRemove BrowsableAPIRenderer from production settings to reduce response payload size and overhead.
Async and Background Tasks
0/5Broker Connectivity and Security
criticalEnsure Celery/Redis connections use TLS/SSL and that the broker is not accessible from the public internet.
Worker Concurrency Limits
recommendedConfigure worker concurrency based on available CPU/RAM to prevent OOM (Out of Memory) kills during peak loads.
Task Result Expiry
recommendedSet CELERY_RESULT_BACKEND_MAX_AGE to prevent the result backend database from growing indefinitely.
Dead Letter Queues
recommendedImplement retry logic with exponential backoff and a dead-letter queue for failing background tasks.
ASGI Timeout Configuration
criticalIf using async views, configure the ASGI server (e.g., Daphne/Uvicorn) timeouts to match the expected load-balancer timeout.
Static Files and Assets
0/5Manifest Storage
recommendedUse ManifestStaticFilesStorage to enable cache-busting by appending MD5 hashes to filenames.
WhiteNoise Integration
recommendedConfigure WhiteNoise or a dedicated CDN to serve static files efficiently without hitting the Django process.
Media File Externalization
criticalEnsure MEDIA_ROOT is pointed to a persistent volume or cloud storage (S3) rather than ephemeral container storage.
Collection Verification
criticalRun 'python manage.py collectstatic --noinput' as part of the CI/CD pipeline to verify asset integrity.
Compression Implementation
recommendedEnable Gzip or Brotli compression for static assets via WhiteNoise or Nginx configuration.
Logging and Monitoring
0/5Structured Logging
recommendedConfigure JSON logging formatters to allow ELK or Splunk stacks to parse Django logs effectively.
Error Tracking Integration
criticalInitialize Sentry or a similar SDK to capture unhandled exceptions and performance bottlenecks.
Health Check Endpoint
criticalImplement a /health/ endpoint that checks database and cache connectivity for load balancer liveness probes.
Query Logging Thresholds
optionalSet up alerts for slow queries exceeding a specific millisecond threshold in the database layer.
Log Rotation
criticalEnsure file-based logs (if used) have rotation policies to prevent disk exhaustion.