I am tring to createsuperuser in a django docker container with fabric.
To create the super user in django, I need run this in a django interactive mode:
./manage.py createsuperuser
And because I want to make it run in a fabric script, so I find this command could avoid inputing password
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'pass')" | ./manage.py shell
Then I put this together with "docker exec" to run it in my django container
docker exec container_django echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', '[email protected]', 'pass')" | ./manage.py shell
The problem comes out with the linux pipe, the pipe(|) all the contents on its left(including the docker exec) to its right(./manage.py shell)
And this is not only difficult part, considering to put all these junks into a fabric run, which means they need quotes on both end. It will make whole thing very urgly.
fabric run:
run("docker exec container_django {command to create django super user}")
I am still struggling on how to make at least the junk work in a fabric run, but I don't know how to do it.