尝试为我的数据库创建超级用户:
manage.py createsuperuser
得到一个悲伤的递归消息:
由于未在TTY中运行,因此跳过了超级用户。您可以在项目中运行manage.py createsuperuser
以手动创建一个。
严重Django?真的吗?
我找到的唯一信息是上面列出的信息,但它不起作用:Unable to create superuser in django due to not working in TTY
而另一个在这里,基本上是相同的:Can't Create Super User Django
如果你跑
$ python manage.py createsuperuser
Superuser creation skipped due to not running in a TTY. You can run manage.py createsuperuser
in your project to create one manually.
from Git Bash and face the above error message try to append winpty
i.e. for example:
$ winpty python manage.py createsuperuser Username (leave blank to use '...'):
为了能够像往常一样在Windows上运行python
命令以及我通常做的是在~/.profile
文件中附加别名行,即
MINGW64 ~$ cat ~/.profile
alias python='winpty python'
执行此操作后,要么获取~/.profile
文件,要么只需重新启动终端,初始命令python manage.py createsuperuser
应该按预期工作!
尝试使用命令:sudo docker exec -i <container_name> sh
在docker容器中创建超级用户时遇到了同样的问题。添加选项-t解决了问题:
sudo docker exec -it <container_name> sh