且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法使用 Django manage.py 创建超级用户

更新时间:2023-09-27 22:23:22

如果你运行

$ 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.

Git Bash 并面对上述错误消息尝试附加 winpty 即例如:

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 文件,即

To be able to run python commands as usual on windows as well what I normally do is appending an alias line to the ~/.profile file i.e.

 MINGW64 ~$ cat ~/.profile
 alias python='winpty python'

这样做之后,要么获取 ~/.profile 文件,要么只是重新启动终端,初始命令 python manage.py createsuperuser 应该会按预期工作!

After doing so, either source the ~/.profile file or simply restart the terminal and the initial command python manage.py createsuperuser should work as expected!