简体   繁体   English

Django manage.py syncdb未创建模型

[英]Django manage.py syncdb not creating models

I have a django project, I have configured the database settings in settings.py, and I have created database models in a file. 我有一个django项目,已经在settings.py中配置了数据库设置,并且已经在文件中创建了数据库模型。 What else do I need to do for manage.py syncdb to create the corresponding tables in my database? 我需要对manage.py syncdb进行什么操作才能在数据库中创建相应的表?

There are two more steps. 还有两个步骤。 First, database models must be in a file called models.py . 首先,数据库模型必须位于名为models.py的文件中。 Other files aren't recognized by django for database models. Django无法识别其他文件的数据库模型。 Second, you need to add an entry to INSTALLED_APPS inside settings.py for the module containing this models.py. 其次,您需要为settings.py中包含此models.py的模块添加一个条目到INSTALLED_APPS So, if you have in your project somedir/models.py , you need to have in your settings.py : 因此,如果您的项目中有somedir/models.py ,则需要在settings.py

INSTALLED_APPS = (
    #...
    "somedir",
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM