开发者

django - Automate creation of models.py file?

Is there a way to automatically create the model开发者_如何转开发s.py model definition when you already have an existing database? I have a complicated database with tables and relationships already setup up in MySQL, and would like to avoid creating the models.py file from scratch if possible.


You can use :

./manage.py inspectdb > models.py

According to the documentation :

The inspectdb utility introspects the database pointed to by your settings file, determines a Django model representation for each of your tables, and prints the Python model code to standard output.

More information in the Django Book 2.0 - Chapter 18:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜