如何将postgres关系导入django 1.8 [英] How to import postgres relations into django 1.8

查看:156
本文介绍了如何将postgres关系导入django 1.8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在postgres中有一个现有的django数据库,它有几个关系。我在django postgres中有一个新模型,我想从现有数据库导入一些有关系的表。我是否需要将旧字段映射到新模型?我如何保持关系?有没有一个工具可以帮助这个过程?

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?

谢谢

推荐答案

使用

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

这篇关于如何将postgres关系导入django 1.8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆