Commit 7ec5db00 authored by Stefan Bienert's avatar Stefan Bienert
Browse files

COntainer: create Django superuser

parent 33ad3fce
...@@ -74,12 +74,15 @@ python3 manage.py collectstatic --noinput ...@@ -74,12 +74,15 @@ python3 manage.py collectstatic --noinput
# create root account for Django admin page # create root account for Django admin page
>&2 echo "Create superuser for the database" >&2 echo "Create superuser for the database"
python3 manage.py shell << END python3 manage.py shell << END
import os
from django.contrib.auth.models import User from django.contrib.auth.models import User
try: try:
User.objects.get(username='admin') User.objects.get(username=os.environ['DJANGO_DB_ADMIN_USR'])
except User.DoesNotExist: except User.DoesNotExist:
User.objects.create_superuser('admin', 'ad@m.in', 'admin') User.objects.create_superuser(os.environ['DJANGO_DB_ADMIN_USR'],
os.environ['DJANGO_DB_ADMIN_ML'],
os.environ['DJANGO_DB_ADMIN_PW'])
except Exception as dexc: except Exception as dexc:
if str(dexc) == 'UNIQUE constraint failed: auth_user.username': if str(dexc) == 'UNIQUE constraint failed: auth_user.username':
pass pass
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment