Biggest Black Friday/Cyber Monday Deals on Hosting, Themes, Plugins, CDN, etc. Go Get Lifetime Deals! Get Now

How to Export Database Diagrams (ERD) from Django?

In this tutorial, we will learn to Export Database diagrams (ERD) from Django. It’s an easy process to export ERD with Django Extensions.

Here, I have tested this service on my windows laptop so, if you are using Linux or Mac, you can follow a similar process.


1. Install Graphviz software in your laptop
2. pip install graphviz
3. pip install django-extensions
4. Go to > add 'django_extensions', to INSTALLED_APPS
5. Add the following code 
    'all_applications': True,
    'graph_models': True,
6. pip install pyparsing pydot
7. py graph_models -a >
8. py graph_models -a
9. py graph_models -a > && py graph_models – pydot -a -g -o erd.png

Steps to Export Database Diagrams (ERD)

When you’re working with a relational database, you’ll need to create some kind of Entity Relationship Diagram (ERD) at some point. ERDs are helpful in visualizing the relationships between database tables and can be a helpful tool for designing or reverse-engineering databases.

Export Database Diagrams (ERD) from Django

1. Install Graphviz software

One of the easiest is to use the open-source Graphviz tool. Graphviz is a set of tools for visualizing graph data, and it’s easy to use with databases.

Since you need to visualize the structural information, install Graphviz software first. Visit the official website and install it according to your operating system.

2. Install graphviz package

Now go to your IDE > Project and Install the graphviz package. Here is the command to install graphviz:

pip install graphviz

3. Install Django Extensions

There are a few reasons to install django-extensions and they are to add functionality to your project, to improve project performance, or to make your project more user-friendly.

pip install django-extensions

4. Add Django Extensions to

Now, it’s time to add ‘django_extensions’.

Go to > add ‘django_extensions’, to INSTALLED_APPS

Adding django_extensions to installed apps.

Also, add the following code in the at the end.

'all_applications': True,
'graph_models': True,

5. Install pyparsing pydot

pyparsing and pydot are both required by the graphviz library. pyparsing is a library for parsing text strings. pydot is a library for creating, manipulating, and visualizing graphs in DOT format.

Now use the following code.

pip install pyparsing pydot
py graph_models -a >
py graph_models -a

8. Export Database Diagrams (ERD)

Now, it’s time to Export Database Diagrams (ERD) using the following code. This will output a file called “” which can be opened with the graphviz program to generate a visual representation of your app’s models and their relationships. This will also generate a file called “erd.png” which is a visual representation of your app’s models and their relationships.

py graph_models -a > && py graph_models – pydot -a -g -o erd.png
Export Database Diagrams (ERD)

Also Read: Integrate Bulma (CSS Framework) in WordPress


Now, open your project folder and locate the erd.png file and see exported Entity-Relationship diagram.
I hope after reading the above guide you are able to export Export Database Diagrams (ERD) in Django Framework.

Recommended Reading...

I am obsessed with WordPress and write articles about WordPress Speed Optimization, SEO, and Blogging. I mostly publish tutorials on GeneratePress, Astra, Kadence, and GenerateBlocks.

2 thoughts on “How to Export Database Diagrams (ERD) from Django?”

  1. Hey Suraj Can You Give Us A Guide On

    How To Add Adblocker In Genratepress Without Plugin [Lite] Which Doesn’t Cause Speed Issue In Website💙


Leave a Comment