How to import postgres relations into django 1.8

泪湿孤枕 提交于 2020-01-17 01:37:14

问题


I have an existing django database in postgres and it has several relationships. I have a new model in django postgres and I want to import some of the tables from existing database which have relationships. Do I need to map old fields to the new model? How do I preserve relationships? Is there a tool that helps in the process?

Thanks


回答1:


use

python manage.py inspectdb

It will create models from your legacy database. Read more here:

https://docs.djangoproject.com/en/1.8/howto/legacy-databases/#integrating-django-with-a-legacy-database



来源:https://stackoverflow.com/questions/29751402/how-to-import-postgres-relations-into-django-1-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!