xu huanze
xu huanze

Reputation: 267

Best way of Django modeling

Currently we are working like this:

  1. Create an EER model using MySQL Workbench, involve at least one person to discuss

  2. Generate tables from EER model

  3. manage.py inspectdb to create models.py, edit models.py carefully as inspectdb does not work perfectly

  4. Coding(now I'm the only coder). Code will be updated if changes are needed to the models, but not to the EER diagram

The problem is that now other team members(now there is only one) feel difficult to discuss for further changes if the diagram is not synchronized. My opinion is that the discussion could be just based on the code, which is also some kind of document. For me there is no big difference to look at the diagram or the code. If we will need to keep the document up to date, for me it looks like some kind of duplication. How do you do this?

We also tried to keep only one source, e.g. code, so everytime we use syncdb to generate tables, and then generate the EER diagram, the problem is auto layout from MySQL Workbench does not work so well, you will always need to rearrange everything. I also found some tool that could convert UML diagrams to models or vice versa, but I doubt if it would work well because I used to use a CASE tool which could generate source code(Java/C++) from UML diagrams as well as documents(e.g. Word) but the tool was not easy to use and I got some problems... my question is then is there a good tool to keep the code and diagrams synchronized easily?

Upvotes: 0

Views: 649

Answers (1)

jpic
jpic

Reputation: 33420

If you just want to generate an updated diagram to work with your team:

  1. Install django-extensions and pygraphiz: pip install pygraphviz django-extensions
  2. Add 'django_extensions' to INSTALLED_APPS: this will enable django-extensions management commands
  3. Generate the graph: ./manage.py graph_models -a -g -o my_project_visualized.png

Read more about the graph_model command.

Upvotes: 2

Related Questions