Deploy Django (w/ Django Rest Framework) and Connect to Database using AWS Elastic Beanstalk

option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: <your_app>.settings
aws:elasticbeanstalk:container:python:
WSGIPath: <your_app>.wsgi:application
NumProcesses: 3
NumThreads: 20
aws:elasticbeanstalk:environment:proxy:staticfiles:
"/static": "static"
container_commands:
01_migrate:
command: "source /var/app/venv/path/to/venv/bin/activate && python3 manage.py migrate --noinput"
leader_only: true
02_collect_static:
command: "source /var/app/path/to/venv/bin/activate && python3 manage.py collectstatic --noinput"
leader_only: true
from django.contrib.auth.models import User
from django.conf import settings
def run():
super_user = User.objects.filter(username='some_admin_username').first()
if super_user:
super_user.is_staff = True
super_user.is_superuser = True
super_user.save()
else:
User.objects.create_superuser("some_admin_username", "super_admin_email", "some_admin_pasword")
03_create_super_user:    command: "source /var/app/venv/staging-LQM1lest/bin/activate && python3 manage.py runscript create_super_user"    leader_only: true

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store