2

I am just half way writing my django application and my employer wants me to fetch him class diagram of the whole code written until now. As I'm really short in timeI started thinking of a tool that will do it for me in a shorter time. I have tried Pyreverse But it seems I can't figure it out.

Steps taken :

I have installed pylint and graphviz

I have tried walkthrough from this post. but it says :

The output format 'png' is currently not available. Please install 'Graphviz' to have other output formats than 'dot' or 'vcg'.

and when I run pip install Graphviz it says :

Requirement already satisfied: Graphviz in c:\users\amin\appdata\local\programs\python\python36-32\lib\site-packages

In the end any suggestions for drawing database diagram of a django code would be appreciated.

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164
AmiNadimi
  • 5,129
  • 3
  • 39
  • 55

2 Answers2

1

1) if you want to draw any diagrams from a python source code that you have, first you should install pylint, type in command line :

pip install pylint

2) then install graphviz :

pip install graphviz
  • in windows you should install graphviz executables from this link because installing the package through pip might not work.

3) then if you want to draw the class diagram for an app, navigate to your project folder via the command line and write :

pyreverse ./appname -o mydiagram.png

then either it works fine or you will have graphviz was not recognized ... error. in case of the error do one of the following :

A. find graphviz executable's location and add them to path environment variable (default is C:\Program Files (x86)\Graphviz2.38\bin). then restart your pc and repeat (3).

B. or navigate to your project folder via the command line and write :

pyreverse ./appname -o mydiagram.dot

you will have a mydiagram.dot file. but it's not the graphical diagram you might need. now find location of dot.exe (it's included in graphviz executables) to convert *.dot to *.png image :

"C:\Program Files (x86)\Graphviz2.38\bin\dot.exe" -Tpng mydiagram.dot -o mydiagram.png

there is an article here if you want to see more dot commands.

AmiNadimi
  • 5,129
  • 3
  • 39
  • 55
0

At the end you ask for a way to draw a database diagram for a Django application. For this I can suggest SchemaSpy. It creates a collection of HTML pages with more than just the diagram, and everything is well organised and you can click your way around parts of the diagram.

jrial
  • 478
  • 4
  • 10