user258857
user258857

Reputation: 31

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. 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/

Upvotes: 3

Views: 1460

Answers (1)

Dmitry Shevchenko
Dmitry Shevchenko

Reputation: 32394

You can look at inspectdb code, and instead of outputting code return classes.

Upvotes: 1

Related Questions