'Run Django manage.py shell commands on elastic beanstalk on AL2
I have my Django service up and running on AWS Elastic Beanstalk (on Amazon Linux 2). eb deploy works perfectly. But I would like to run some functions from shell of Django on by eb or maybe perform migrations on my DB.
I am unable to find my package after I eb ssh <environment-name> so cant find the manage.py file.
Related question - Run manage.py from AWS EB Linux instance
I believe it might be outdated ?
djangoamazon-web-services">
amazon-web-servicesamazon-elastic-beanstalk">
amazon-elastic-beanstalkamazon-linux-2makemigrations
Solution 1:[1]
Change to the current app directory
cd /var/app/current/
Change to the staging app directory (only exists after a failed eb deploy)
cd /var/app/staging/
Activate the virtual env
source $(find /var/app/venv/*/bin/activate)
Load your environment variables
export $(sudo cat /opt/elasticbeanstalk/deployment/env | xargs)
Now you can run management commands
python manage.py shell
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Art |
