I want to auto run manage.py createsuperuser
on django
but it seams that there is no way of setting a default password.
How can I get this?
This is what I cobbled together for Heroku post_deploy and a predefined app.json variable:
if [[ -n "$CREATE_SUPER_USER" ]]; then
echo "==> Creating super user"
cd /app/example_project/src
printf "from django.contrib.auth.models import User\nif not User.objects.exists(): User.objects.create_superuser(*'$CREATE_SUPER_USER'.split(':'))" | python /app/example_project/manage.py shell
fi
With this you can have a single env variable:
CREATE_SUPER_USER=admin:admin@example.com:password
I like the shell --command option, but not sure how the get newline character in the command script. Without the newline the if
expression results in syntax error.