How to run python manage.py createsuperuser?
robbiibadi opened this issue · comments
please help me, i wan to create superuser, how to create it ? thank you
Hey, @robbiibadi
Try something like this:
docker-compose run django python manage.py createsuperuser
This code runs 'python manage.py createsuperuser' in django
container
its work thank you @vchaptsev
Hi @vchaptsev
Me again, I tried running that command and I get this error:
No such service: django
Any suggestions?
Hey!
Now it is backend
docker-compose run backend python manage.py createsuperuser
Hi @vchaptsev
Successfully created a user - one more question. How do I access the vue-cli from docker?
Kind Regards
Werner
Something like this:
docker-compose run frontend <your command>
# for example:
docker-compose run frontend npm run lint
Okay awesome! It worked - thank you so much for helping me out.
docker-compose run backend python manage.py createsuperuser
gives me ERROR: No such service: backend
both commands don't work for me. Any other ideas?
Nevermind I found a solution
First ran this migrate command - this is the only one that worked for in a docker container:
sudo docker-compose run web python manage.py migrate
Then ran this command:
docker exec -it <dockercontainerid> python manage.py createsuperuser
Although this issue is closed long time ago
But as for me using latest docker(unsure which version)
I simply run a create_admin.py using
CMD [ "python", "create_admin.py"]
in that create_admin.py
from django.contrib.auth import get_user_model
User = get_user_model()
User.objects.create_superuser('admin', 'admin@gmail.com', 'admin')
Just for some reference and some random comment.
Hope this helps.
Nevermind I found a solution
First ran this migrate command - this is the only one that worked for in a docker container:
sudo docker-compose run web python manage.py migrate
Then ran this command:
docker exec -it <dockercontainerid> python manage.py createsuperuser
it helped me alot ! tyvm !