Linux
Install
pygraphviz
sudo apt-get install graphviz graphviz-dev
# if you are using conda
conda install --channel conda-forge pygraphviz
# if you are using venv
pip install pygraphviz
# django_extensions
pip install django-extensions
# add in settings.py
INSTALLED_APPS = [
...
'django_extensions',
...
]
Â
Windows
You need to have Chocolatey installed in your system
Install
pygraphviz
choco install graphviz
# in your venv
python -m pip install --global-option=build_ext --global-option="-IC:\Program Files\Graphviz\include" --global-option="-LC:\Program Files\Graphviz\lib" pygraphviz
Â
Examples
#To group all the application and output into PNG file
$ python manage.py graph_models -a -g -o imagefile_name.png
#Include only some applications
$ python manage.py graph_models app1 app2 -o app1_app2.png
#Include only some specific models
$ python manage.py graph_models -a -I Foo,Bar -o foo_bar.png
#OR exclude certain models
$ python manage.py graph_models -a X Foo,Bar -o no_foo_bar.png
Â
Â