基于现有数据库表创建动态Django模型 [英] Dynamic Django model creation based on existing DB table
本文介绍了基于现有数据库表创建动态Django模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
请查看 inspectdb code ,以及而不是输出代码返回类。
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. 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/
解决方案
You can look at inspectdb code, and instead of outputting code return classes.
这篇关于基于现有数据库表创建动态Django模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文