Django manage.py未知命令:“syncdb”

2024-06-01 00:38:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着跟着this tutorial走,但我被困在第五步。

当我执行时

[~/Django Projects/netmag$]python manage.py syncdb

我收到以下错误消息:

Unknown command: 'syncdb'
Type 'manage.py help' for usage.

这里是./manage.py help不包含syncdb命令的输出。如何添加?

谢谢你的帮助!

编辑:

运行migrate时,会出现以下错误:

"Error creating new content types. Please make sure contenttypes " RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.

在settings.py中:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admindocs',
    'blog',
]

编辑2:

如果我从settings.py中删除'blog',

:~/Django Projects/netmag$ python manage.py migrate blog
CommandError: App 'blog' does not have migrations. 

:~/Django Projects/netmag$ python manage.py makemigrations blog 
App 'blog' could not be found. Is it in INSTALLED_APPS?

Tags: djangopy编辑manage错误helpblogerror
3条回答

在django 1.7中,syncdb命令是deprecated。改用python manage.py migrate

您必须使用python manage.py migrate,而不是python manage.py syncdb

运行python manage.py makemigrations结果低于

Migrations for 'blog':
blog/migrations/0001_initial.py:
- Create model Blog

之后运行python manage.py migrate结果低于

Operations to perform:
Apply all migrations: admin, blog, auth, contenttypes, sessions
Running migrations:
Applying article.0001_initial... OK

相关问题 更多 >