Visualize Django Models

The django-extensions contain a great command to visualize the model hierarchy of a Django project:

$ apt-get install graphviz
$ pip install pygraphviz
$ pip install django-extensions
# In your Django settings
INSTALLED_APPS = [
    "django_extensions",
]

Then you can get a zoomable vector graphic from all models of one app like so:

$ python manage.py graph_models my_app -o my_app_models.svg

The result may look like below, but make sure to explore the command options, it can be customized alot especially when you want to limit which models to draw.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s