Deployment & Settings
Snippets for Django deployment and settings management, including environment variables, multiple settings files, and production best practices.
Using Environment Variables
Store sensitive data in environment variables with os.environ.
Split Settings for Dev and Prod
Organize settings by splitting them into dev, staging, and prod files.
Configure Allowed Hosts
Set ALLOWED_HOSTS to restrict incoming host headers.
Configure Django Logging
Set up logging configuration in Django settings.
Static and Media Settings
Configure STATIC_URL and MEDIA_URL for deployment.
Use django-environ for Config
Simplify environment variable management with django-environ.
Setup WSGI for Deployment
Deploy Django apps with WSGI using Gunicorn or uWSGI.
Setup ASGI for Async Deployment
Deploy Django with ASGI for async features like WebSockets.
Gunicorn Deployment Example
Run Django apps in production using Gunicorn WSGI server.
Nginx Configuration for Django
Configure Nginx to serve Django apps with Gunicorn or Uvicorn.