我从djangoproject.com开始学习第一个django教程,并在第2部分的开头,当我运行"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.
当我在运行syncdb
之后继续创建超级用户时,我收到相同的消息。
我正在使用Eclipse for Windows 7,以及Django 1.7.1和Python 2.7.8。
当使用Git Bash并纠正上述错误消息时,请尝试附加winpty
即,例如:
$ winpty python manage.py createsuperuser
Username (leave blank to use '...'):
如果你在virtualenv,cd
进入你的virtualenv并激活它。然后尝试以下步骤:
python manage.py syncdb --noinput
python manage.py migrate
python manage.py createsuperuser
您可以使用django shell创建超级用户(python manage.py shell
)
from django.contrib.auth.models import User
User.objects.create_superuser(username='YourUsername', password='hunter2', email='[email protected]')
我是Windows10用户。我尝试使用py manage.py createsuperuser
控制台运行Git Bash
命令,但错误已被抛出。然后我用管理员权限将Git Bash
切换到本机Windows Command Line
,并重新运行命令 - 它正在工作。
使用“Windows PowerShell”或“Windows Cmd”,然后使用相同的命令。 Git命令界面有一些限制。
第一次运行
cmd提示符中的$ django-admin startproject mysite,然后应用迁移
cd然后我的:
python manage.py makemigrations然后
python manage.py之后迁移
python manage.py createsuperuser