Dash is open source web application framework to create interactive web-based visualizations. It was developed based on Flask, Plotly.js, and React.js libraries. We may also want to use the power of this web framework in Django projects. I will explain how to do this in this post.

We will use the django_plotly_dash package developed to use Dash in Django projects.

1. Installation

Firstly, Use pip package manager to install the package as follows;

pip install django_plotly_dash

Then, we add django_plotly_dash to INSTALLED_APPS in the Django file.


Also, we add the following line to the file.


The application’s routes need to be registered within the routing structure by an appropriate include statement in a file as follows;

    path('django_plotly_dash/', include('django_plotly_dash.urls')),

File structure of is as follows;

For the final installation step, a migration is needed to update the database:

python migrate 

2 . Running the First Application

We are also creating our django application called dashreporting where we will collect our Dash applications.

python startapp dashreporting

We register our dashreporting application to INSTALLED_APPS in file.

We create a folder named dash_apps under the dashreporting folder to collect our Dash apps in a folder.

Also we create in dashreporting application. We need to import our apps into ‘file. We need to import our apps into ‘file. We define paths in and define which view functions will work.

We define the view functions that will work in our dashreporting application.

We create our first dash application by creating an file in the dash_apps folder.

We use DjangoDash (‘SimpleExample’) instead of dash.Dash () used to create the dash app in Django. In addition, we give the name of the app we will use in template as an argument. Here we set it as ‘SimpleExample’.

Finally, it is left to render our dash report in our template. For this, we add the following template tags in our template.

{%load plotly_dash%}
{%plotly_app name="SimpleExample"%}

We will get our Dash graph in web browser as follows;