我从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。
答案 0 :(得分:8)
使用Git Bash并更正上述错误消息时,请尝试附加winpty
例如:
$ winpty python manage.py createsuperuser
Username (leave blank to use '...'):
答案 1 :(得分:4)
如果你在virtualenv,cd
进入你的virtualenv并激活它。然后尝试以下步骤:
python manage.py syncdb --noinput
python manage.py migrate
python manage.py createsuperuser
答案 2 :(得分:2)
您可以使用django shell(python manage.py shell
)
from django.contrib.auth.models import User
User.objects.create_superuser(username='YourUsername', password='hunter2', email='your@email.com')
答案 3 :(得分:1)
我是Windows10用户。我尝试使用py manage.py createsuperuser
控制台运行Git Bash
命令,但是已经抛出了错误。然后我使用管理员权限将Git Bash
切换为原始Windows Command Line
,然后重新运行命令 - 它正在运行。
答案 4 :(得分:0)
使用" Windows PowerShell"或者" Windows Cmd"然后使用相同的命令。 Git命令界面有一些限制。
答案 5 :(得分:0)
首次运行
$ django-admin startproject mysite 在cmd提示符下,然后应用迁移方式
cd mysite mysite:
python manage.py makemigrations 然后
python manage.py迁移 之后
python manage.py createsuperuser
答案 6 :(得分:0)
使用此命令:
[Error `You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, content types, sessions.
Run 'python manage.py migrate' to apply them.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 303, in execute
return Database.Cursor.execute(self, query, params)`][1]
您的错误可能是:
python3 manage.py createsuperuser
使用Tree命令检查您的目录:tree
然后运行进行迁移: enter image description here
然后使用{{1}}命令创建超级用户: