Django管理。py未知的命令:“syncdb”

时间:2022-06-12 23:18:55

I'm trying to follow this tutorial but I'm stuck on the 5th step.

我正在努力学习本教程,但是我被困在了第五步。

When I execute

当我执行

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

python(~ / / netmag $ Django项目)管理。py syncdb

I get the following error message :

我得到以下错误信息:

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

and here is the output of ./manage.py help does not contain syncdb command. How do I add it?

这是输出。/管理。py帮助不包含syncdb命令。怎么加呢?

Thanks for any help!

感谢任何帮助!

Edit :

When I run migrate, I get this error :

当我运行migration时,我得到这个错误:

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

创建新内容类型时出错。请确保内容类型“运行时错误:创建新内容类型的错误”。在尝试单独迁移应用程序之前,请确保已经迁移了contenttype。

in settings.py :

在设置。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',
]

Edit 2:

If I remove 'blog', from settings.py :

如果我从设置中删除“blog”。py:

:~/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?

3 个解决方案

#1


164  

syncdb command is deprecated in django 1.7. Use the python manage.py migrate instead.

在django 1.7中,不赞成使用syncdb命令。使用python管理。py迁移。

#2


11  

You have to use python manage.py migrate instead rather than python manage.py syncdb

您必须使用python管理。而是迁移py而不是python管理。py syncdb

#3


5  

Run python manage.py makemigrations result below

python运行管理。py makemigrations下面的结果

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

and after that run python manage.py migrate result below

然后运行python管理。py迁移结果低于

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

#1


164  

syncdb command is deprecated in django 1.7. Use the python manage.py migrate instead.

在django 1.7中,不赞成使用syncdb命令。使用python管理。py迁移。

#2


11  

You have to use python manage.py migrate instead rather than python manage.py syncdb

您必须使用python管理。而是迁移py而不是python管理。py syncdb

#3


5  

Run python manage.py makemigrations result below

python运行管理。py makemigrations下面的结果

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

and after that run python manage.py migrate result below

然后运行python管理。py迁移结果低于

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