执行命令python manage.py syncdb
,出现下面的异常:
F:\pythonwork\mysite>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line
367, in execute_from_command_line
utility.execute()
File "D:\Python27\lib\site-packages\django\core\management\__init__.py", line
341, in execute
django.setup()
File "D:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\Python27\lib\site-packages\django\apps\registry.py", line 85, in popu
late
app_config = AppConfig.create(entry)
File "D:\Python27\lib\site-packages\django\apps\config.py", line 123, in creat
e
import_module(entry)
File "D:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named blog
错误比较明显说的是没有找到blog这个应用,
查看INSTALLED_APPS中我写的是mysite.blog
,我参考的是Jeff Forcier Paul Bissex Wesley Chun著的《Django Web开发指南》第2.3章节的做的,有问题。原因是我blog应用跟mysite是平级的,而书上的blog是在mysite下面,所以我得改成blog
,再次执行python manage.py syncdb
Unknown command: 'syncdb'
Type 'manage.py help' for usage.
查查资料原来syncdb command is deprecated in django 1.7
,于是换成了命令
python manage.py migrate
,执行成功