'Using django-extensions to generate a model graph in PNG format using Windows 10 (without using Conda or Anaconda)
I am using django-extensions to generate a model graph for my Django application.
My installation steps are the following:
$ pip install django-extensions
$ pip install pyparsing pydot
An installation of pygraphviz
fails (as described) due to missing C extensions:
$ pip install pygraphviz # this does not work
Now, using the pydot
option from the graph_models
documentation works for .dot
files:
$ python manage.py graph_models -a -I Device,Vehicle -o my_project_subsystem.dot
But creating PNG files breaks and indicates that dot
is not on PATH
:
$ python manage.py graph_models --pydot -a -g -o my_project_visualized.png
with an error:
FileNotFoundError: [WinError 2] "dot" not found in path
A fix to this problem using conda
and pygraphviz
is provided in this answer.
But how can I create graphs with only using pip
without using anaconda
?
To me, it does not matter if use pydot
or pygraphviz
. I just want to create models into PNG files.
Thanks in advance!
Solution 1:[1]
It took a while but I got it working using the following steps:
- Install django extensions via
$ pip install django-extensions==3.1.5
- Install pydotplus via
$ pip install pydotplus==2.0.2
- Install GraphViz via installer and MANUALLY add it to the user
PATH
Include django_extensions
in settings.py
:
INSTALLED_APPS = (
...
'django_extensions',
...
)
Run command:
$ python manage.py graph_models -a -o myapp_models.png
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cigien |