Generating ERD for Django Applications

Generating an ERD (Entity Relationship Diagram) can be helpful to understand what your database looks like, and is also really easy to generate if you’re running a Python/Django Application.

Step 1: Install django-extensions and graphviz

 pip install django-extensions && pip install graphviz

Step 2: Add django_extensions to


Step 3: Create the .dot output and convert to .png

Run graph_models from the environment you may normally use:

python graph_models -a >

From your mac, change the format to png using graphviz

brew install graphviz
dot -Tpng -o output.png

Note You can also output to pdf by changing the type:

dot -Tpdf -o output.pdf

Django Extensions graph_models docs
Django Extensions Commands Unavailable?
Opening .dot files on mac

2 thoughts on “Generating ERD for Django Applications

  1. Thanks for this post, your How-To worked perfectly and helped us a lot. My first idea was to generate the ERD from the database, but we couldn’t access it with tools like DBeaver. It was a new and exciting experience to generate it from Django.
    The landscape photo on top is distractingly beautiful.

  2. Very helpful. Just converted my raw model schema to an png image within a minute . Thanks .

Leave a Reply

Your email address will not be published. Required fields are marked *