pythondjangodiagrampyreverse

draw class diagram for django application


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.


Solution

  • 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
    

    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.