Python Django manage.py 未知命令:'syncdb'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28444614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Django manage.py Unknown command: 'syncdb'
提问by jeff
I'm trying to follow this tutorialbut I'm stuck on the 5th step.
我正在尝试按照本教程进行操作,但卡在第 5 步上。
When I execute
当我执行
[~/Django Projects/netmag$] python manage.py syncdb
[~/Django 项目/netmag$] python manage.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?
这是./manage.py help
不包含syncdb
命令的输出。我如何添加它?
Thanks for any help!
谢谢你的帮助!
Edit :
编辑 :
When I run migrate, I get this error :
当我运行迁移时,我收到此错误:
"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.
“创建新内容类型时出错。请确保 contenttypes” RuntimeError:创建新内容类型时出错。在尝试单独迁移应用程序之前,请确保已迁移 contenttypes。
in settings.py :
在 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',
]
Edit 2:
编辑2:
If I remove 'blog',
from settings.py :
如果我'blog',
从 settings.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?
回答by catavaran
syncdb
command is deprecatedin django 1.7. Use the python manage.py migrate
instead.
syncdb
命令在 django 1.7 中已弃用。使用python manage.py migrate
来代替。
回答by sohil sharma
You have to use python manage.py migrate
instead rather than python manage.py syncdb
你必须使用python manage.py migrate
而不是python manage.py syncdb
回答by Kishore Chandra
Runpython manage.py makemigrations
result below
运行python manage.py makemigrations
结果如下
Migrations for 'blog':
blog/migrations/0001_initial.py:
- Create model Blog
and after that runpython manage.py migrate
result below
然后运行python manage.py migrate
结果如下
Operations to perform:
Apply all migrations: admin, blog, auth, contenttypes, sessions
Running migrations:
Applying article.0001_initial... OK
回答by Marc Guvenc
You can do it like this in stages, let's say you have an app called "example":
您可以分阶段执行此操作,假设您有一个名为“example”的应用程序:
- Run python manage.py makemigrations example
- A number generates like '0001' get the number
- Run python manage.py sqlmigrate example 0001, using the number. Check out the scripts.
- Run python manage.py migrate example 0001
- 运行 python manage.py makemigrations 示例
- 一个数字生成像 '0001' 获取数字
- 使用编号运行 python manage.py sqlmigrate 示例 0001。查看脚本。
- 运行 python manage.py migrate 示例 0001
You can also look at all your migrations like this: python manage.py showmigrations
.
If you don't want to commit it, go to the folder and move it somewhere or delete it before doing step 4.
您还可以查看所有的迁移是这样的:python manage.py showmigrations
。
如果您不想提交它,请在执行步骤 4 之前转到该文件夹并将其移动到某个位置或将其删除。