Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pbansal
Test-Docker
Commits
7ec5db00
Commit
7ec5db00
authored
Aug 29, 2019
by
Stefan Bienert
Browse files
COntainer: create Django superuser
parent
33ad3fce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Docker/cathapi/entrypoint.sh
View file @
7ec5db00
...
...
@@ -74,12 +74,15 @@ python3 manage.py collectstatic --noinput
# create root account for Django admin page
>
&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
try:
User.objects.get(username=
'admin'
)
User.objects.get(username=
os.environ['DJANGO_DB_ADMIN_USR']
)
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:
if str(dexc) == 'UNIQUE constraint failed: auth_user.username':
pass
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment