Junior — Middle
What commands or console commands are typically used to deploy a Django application to a production environment?
sobes.tech AI
Answer from AI
The following commands and steps are typically used for deploying a Django application:
- Prepare the environment: install dependencies from
requirements.txt:
pip install -r requirements.txt
- Apply database migrations:
python manage.py migrate
- Collect static files:
python manage.py collectstatic
- Start the application server (e.g., Gunicorn):
gunicorn myproject.wsgi:application
-
Configure the web server (Nginx, Apache) to proxy requests to Gunicorn.
-
Restart services after code updates (e.g., systemctl restart gunicorn).
These commands are usually executed on the server as part of deployment scripts or CI/CD pipelines.