2

I designed a database using MySQLWorkbench EER model with many foreign key relationships and tables using Django default naming conventions (like using id for primary keys, *_id for foreign keys). Now that I feel that I have a good back-end design, how do I convert that into a Django Python code for models.py? Do I have to manually type out every table?

I read that there is already a UML to Django conversation and I also know MySQLWorkbench can export and "Forward Engineer SQL CREATE script". But I'm not sure if MySQLWorkbench can export a UML diagram.

Also another question, I have an order table that has 3 foreign keys to the user table. The three foreign keys are user_created, user_modified, and user_status. I know that normally Django would create a foreign key called user_id, but what if I need three distinct foreign key from one table?

dgilperez
  • 10,716
  • 8
  • 68
  • 96
hobbes3
  • 28,078
  • 24
  • 87
  • 116
  • 3
    This seems to be a duplicate of http://stackoverflow.com/questions/1179469/is-it-posible-to-generate-django-models-from-the-database. The answer to your question is there. – Sergio Feb 24 '12 at 17:30

2 Answers2

4

It's an old post, but here is an MySQL Workbench Module to export a Django model.py http://sourceforge.net/p/mysqlworkbenchdjangomodule

Daniel
  • 41
  • 2
  • Please don't answer with a link. Links to more information is appreciated, but you should at least summarize the information your trying to give. – Daniel Rosenthal Aug 19 '13 at 14:14
  • It's an MySQL Workbench Module to export a Django model.py file. What should i say more? – Daniel Aug 22 '13 at 11:12
2

But you can "Forward Engineer SQL CREATE script" and afterwards proceed as described in this thread: Is it possible to generate django models from the database?

Community
  • 1
  • 1
feeela
  • 29,399
  • 7
  • 59
  • 71
  • Thanks. I am assuming `inspectdb` won't be _smart_ enough to figure out a join table for M-M relationships, but it's a start! – hobbes3 Feb 24 '12 at 21:17