How to Run the Shell for a Django Project within AWS Elastic Beanstalk AMI
See Django: Tips and Tricks for similar articles.I added slugs to several models after I already had data for those models. To get the slugs saved, I had to save each object corresponding to the model, which is easy programmatically, but a pain to do through the admin interface. My project runs on AWS Elastic Beanstalk, so I needed access to the shell. I found the solution here.
To run the shell for a Django app running on AWS Elastic Beanstalk, you run the following at the command line:
eb ssh
source /opt/python/run/venv/bin/activate
source /opt/python/current/env
cd /opt/python/current/app
python manage.py shell
Then you can do whatever it is you need to do. For me that was:
from xyz.models import Xyz
items = Xyz.objects.all()
for i in items:
i.save()
Then when you're ready to exit the shell and SSH, run the following:
exit()
- to exit the shellexit
- to exit SSH
Related Articles
- Connecting Django and Vue
- Creating RSS Feeds with Django
- How to Run the Shell for a Django Project within AWS Elastic Beanstalk AMI (this article)