数据库优先Django模型 [英] Database first Django models

查看:51
本文介绍了数据库优先Django模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ASP.NET中,首先存在数据库的实体框架或称为代码的东西.Django有类似的东西吗?我通常使用一个需要为之创建后端(然后是前端)的现有数据库.其中一些RDB具有许多表和关系,因此手动编写模型不是一个好主意.我曾向Google寻求解决方案,但相对而言是空手而归.思想将不胜感激.

In ASP.NET there is entity framework or something called code first from database. Is there something similar for Django? I usually work with a pre-existing database that I need to create a backend (and subsequently a front end) for. Some of these RDBs have many tables and relations so manually writing models isn't a good idea. I've scoured Google for solutions but have come up relatively empty handed. Thoughts would be appreciated.

谢谢!

推荐答案

您可以使用此链接上的信息.

You can use the information on this link.

python manage.py inspectdb > models.py

https://docs.djangoproject.com/en/3.0/howto/旧数据库/这取决于您的数据库,但是我已经使用它并且很好.

https://docs.djangoproject.com/en/3.0/howto/legacy-databases/ It depends on your database, but I've worked with it and is good.

这篇关于数据库优先Django模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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