问题
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