简体   繁体   English

基于现有DB表的动态Django模型创建

[英]Dynamic Django model creation based on existing DB table

I'm trying to figure out how I can use the type() module to dynamically create a Django model based on existing DB tables without having to either write it out manually or use the manage.py generator to inspect the DB. 我试图找出如何使用type()模块动态创建基于现有数据库表的Django模型,而无需手动写出或使用manage.py生成器检查数据库。 Reason is my schema changes frequently -- adding new tables, adding/deleting columns, etc. Anyone have a good solution? 原因是我的架构经常更改 - 添加新表,添加/删除列等。任何人都有一个很好的解决方案? Something similar to this would be awesome: http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/ 类似的东西会很棒: http//www.b-list.org/weblog/2008/nov/09/dynamic-forms/

您可以查看inspectdb代码 ,而不是输出代码返回类。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM