Skip to content

Instantly share code, notes, and snippets.

@perrygeo
Created April 13, 2013 21:44
Show Gist options
  • Save perrygeo/5380196 to your computer and use it in GitHub Desktop.
Save perrygeo/5380196 to your computer and use it in GitHub Desktop.
Generate UML diagram of django app models
apt-get install python-pygraphviz
pip install django-extensions
# add 'django_extensions' to INSTALLED_APPS in settings.py
python manage.py graph_models trees -o test.png
@caot
Copy link

caot commented Nov 12, 2018

Is there a way to generate a graph of a selected set of models and the related only?

@mcardozo
Copy link

mcardozo commented Jan 3, 2019

For anyone with @leonel-lordford problem of Template-Does-Not-Exist ensure that you enable App_Dirs under the template settings in your chosen settings file. That worked for me!

and for me! thank you!

@wesvetter
Copy link

@browniebroke thanks for this tip! I couldn't get graphviz working but the dot output worked so I was able to get a graph via your link.

@moojen
Copy link

moojen commented May 20, 2020

Thanks, @syabro your command worked for me (on macOS 10.13.5)! :)

@syabro Same here, worked after using brew (on macOS 10.15.4). Cheers!!

@jhonvidal
Copy link

Get it working, thanks.

I have a question, the graph only shows me the attributes of all kinds.

How can I get it to also show the methods of all classes?

@jhonvidal
Copy link

Thanks, @syabro your command worked for me (on macOS 10.13.5)! :)

@syabro Same here, worked after using brew (on macOS 10.15.4). Cheers!!

Do you know how to also show the methods of a class?

@AgustinPardo
Copy link

How to only show one app diagram?

@dunmininu
Copy link

is there a way I can customize the output (image generated)?
and also the many to many tables are not being generated. How do I go about it please?

@lalit97
Copy link

lalit97 commented Jun 21, 2022

these steps worked for me on ubuntu 20.04

sudo apt install graphviz
pip install django-extensions
pip install pyparsing pydot
python manage.py graph_models -a -o diagram.png
python manage.py graph_models -a -g -o diagram-grouped.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment