无法使用Django manage.py创建超级用户 [英] Not able to create super user with Django manage.py

查看:467
本文介绍了无法使用Django manage.py创建超级用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试为我的数据库创建一个超级用户:

  manage.py createsuperuser 

收到令人遗憾的递归消息:



由于未跳过超级用户创建,在TTY中运行。您可以在项目中运行 manage.py createsuperuser 手动创建一个。



严重的Django?认真吗?



我为此找到的唯一信息是上面列出的信息,但它不起作用:



这里的另一个基本相同:
无法创建超级用户Django

解决方案

如果您运行

 $ python manage.py createsuperuser 
由于未在TTY中运行,因此跳过了超级用户创建。您可以在项目中运行 manage.py createsuperuser 手动创建一个。从 Git Bash 遇到上述错误消息尝试附加 winpty 即例如

 $ winpty python manage.py createsuperuser 
用户名(保留空白以使用'...'):

能够运行 python 在Windows上像往常一样执行命令,以及我通常所做的是在〜/ .profile 文件中添加别名行,即

  MINGW64〜$ cat〜/ .profile 
别名python ='winpty python'

这样做之后,要么获取〜/ .profile 文件,要么直接重新启动终端和初始命令 python manage.py createsuperuser 应该可以正常工作!


Trying to create a super user for my database:

manage.py createsuperuser

Getting a sad recursive message:

Superuser creation skipped due to not running in a TTY. You can run manage.py createsuperuser in your project to create one manually.

Seriously Django? Seriously?

The only information I found for this was the one listed above but it didn't work: Unable to create superuser in django due to not working in TTY

And this other one here, which is basically the same: Can't Create Super User Django

解决方案

If you run

$ 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 '...'):

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'

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!

这篇关于无法使用Django manage.py创建超级用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆