$ python manage.py createsuperuser
user@host> manage.py shell
>>> from django.contrib.auth.models import User
>>> user=User.objects.create_user('foo', password='bar')
>>> user.is_superuser=True
>>> user.is_staff=True
>>> user.save()
python manage.py createsuperuser
#Put this in your terminal, then input your username, email address, and password twice.
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
class Command(BaseCommand):
def handle(self, *args, **options):
# The magic line
User.objects.create_user(username= 'rmx',
email='superuser@super.com',
password='rmx55',
is_staff=True,
is_active=True,
is_superuser=True
)
$ python manage.py createsuperuser
Username (leave blank to use 'computername'):
Email:
Password:
Password (again):
Superuser created successfully.
//the terminal will not show your password as you type for security reasons
echo "from django.contrib.auth import get_user_model; User = get_user_model(); User.objects.create_superuser('userUsername', 'userEmail', 'userPassword')" | python manage.py shell
# go to https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-update-app
# copy the code
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
option_settings:
aws:elasticbeanstalk:application:environment:
DJANGO_SETTINGS_MODULE: ebdjango.settings
# on terminal run
nano .ebextentions/db-migrate.config
# paste the above copied code and change DJANGO_SETTINGS_MODULE to
DJANGO_SETTINGS_MODULE: project-name.settings
# now create superusesr using following code
02_createsuperuser:
command: "echo "from django.contrib.auth.models import User; User.objects.create_superuser('vipin', 'vyvipinyadav998@gmail.com', 'django1234')" | python manage.py shell"
leader_only: true
#save this file and run "eb deploy" on terminal