mysqldjangomysql-workbencheer-model

How do I go from a MySQLWorkbench EER model (ERD) to Django?


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?


Solution

  • 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?