Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Django_plotly_dash with Apache and mod_wsgi is not working

Hello All,

Greetings of the new year.

I am trying to use Plotly Dash with Django app for creating a Dhasboard page. I used the django_plotly_dash package and made all the configuration as per the documentation. The page is working fine when I am running locally with python runserver but when I am deploying to UAT its failing. The UAT Django app is running on Windows Server + Apache httpd server + mod_wsgi +python 3.9 +Django 3.0. 10

I dont get any error in the apache server log , the application just stop responding to any http request. All the request queue up in pending state with django_ploty_dash config enabled. If I remove the configuration for django_plotly_dash the application starts responding again.

plotly file:

import dash

import dash_core_components as dcc

import dash_html_components as html

from dash.dependencies import Input,Output

import plotly.graph_objs as go

import pandas as pd

from django_plotly_dash import DjangoDash

import dash_bootstrap_components as dbc

df = pd.read_csv(‘C:/Data/gapminderDataFiveYear.csv’)

app = DjangoDash(‘SimpleExample’,add_bootstrap_links=True,external_stylesheets=[dbc.themes.BOOTSTRAP])

year_options =

for year in df[‘year’].unique():


app.layout = html.Div([






def update_figure(selected_year):

#Filtered Dataframe based on selected year

filtered_df = df[df['year'] == selected_year]

traces =[]

for continent_name in filtered_df['continent'].unique():

    df_by_continent = filtered_df[filtered_df['continent'] == continent_name]


        x= df_by_continent['gdpPercap'],

        y = df_by_continent['lifeExp'],






return {'data':traces,

        'layout':go.Layout(title='Graph for Demo',

                            xaxis={'title':'GDP Per Capita','type':'log'},

                            yaxis={'title':'Life Expectancy'})


django app

























ROOT_URLCONF = ‘dse_application.urls’



    'BACKEND': 'django.template.backends.django.DjangoTemplates',

    'DIRS': [BASE_DIR/'templates'],

    'APP_DIRS': True,

    'OPTIONS': {

        'context_processors': [










WSGI_APPLICATION = ‘dse_application.wsgi.application’


Settings | Django documentation | Django


 'default': {

    'ENGINE': 'django.db.backends.sqlite3',

     'NAME': str(os.path.join(BASE_DIR, "db.sqlite3")),



#BASE_DIR / ‘db.sqlite3’,

Password validation

Settings | Django documentation | Django



    'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',



    'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',



    'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',



    'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',




Internationalization and localization | Django documentation | Django



USE_I18N = True

USE_L10N = True

USE_TZ = True

Static files (CSS, JavaScript, Images)

Managing static files (e.g. images, JavaScript, CSS) | Django documentation | Django

STATIC_URL = ‘/static/’

#for PROD

STATIC_ROOT = ‘/static/’

MEDIA_URL = ‘/media/’

MEDIA_ROOT = PureWindowsPath(’//shareddrive/’).drive

Settings for Plotly Dashboard integration


# Route used for the message pipe websocket connection

#"ws_route" :   "dpd/ws/channel",

# Route used for direct http insertion of pipe messages

#"http_route" : "dpd/views",

# Flag controlling existince of http poke endpoint

#"http_poke_enabled" : True,

# Insert data for the demo when migrating

#"insert_demo_migrations" : False,

# Timeout for caching of initial arguments in seconds

#"cache_timeout_initial_arguments": 60,

# Name of view wrapping function

#"view_decorator": None,

# Flag to control location of initial argument storage

#"cache_arguments": True,

# Flag controlling local serving of assets

"serve_locally": True,


Staticfiles finders for locating dash app assets and related files








Plotly components containing static content that should

be handled by the Django staticfiles infrastructure


# Common components




# django-plotly-dash components


# static support if serving local assets


# Other components, as needed




from graph_interaction_demo import app

urlpatterns = [





path('login/', RedirectView.as_view(url='/admin'),name='login'), 




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


urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

Any suggestion what could be the issue or how to resolve this would be a great help.
Thank you in advance.

This sounds like some piece isn’t correctly configured for the apache server. Are you able to coax any error or other logging at all out of the process?

I’ve not had any cause to use Apache for serving Django for a long time, and definitely not on Windows, but this section on debugging techniques for the wsgi module might help you extract some useful information.

Thanks delsim for sharing the link. I will try the options.

hi @delsim , I tried the debugging process but there is nothing in the logs. Any http request to the server, just stays in pending state and nothing proceeds further. As soon as I remove django_plotly_dash configurations from, and restart the server everything start working smoothly again

This sounds like the python is not loading in your environment. Is it not possible to add some sort of logging (eg in or in the main file) that lets you know that the application is loading?

hi @delsim ,
I implemented logger in all the files and what I can debug is the problem is, the import statement of the plotly_dash file in the main

from . import graph_interaction_demo

the moment I comment this line the whole portal works fine except the page where the plotly_dash app is
integrated. The plotly_dash integrated page shows error ‘Unable to find stateless DjangoApp called simpleexample’
Any suggestion what could be the problem?

It sounds like something is going wrong when you import the graph_interaction_demo file, which I assume contains your application. The ‘Unable to find…’ error is simply the application reporting that you’ve not imported it.

First, I’d recommend making it an absolute, not a relative, import. If you can’t log any errors from importing it, then I would proceed by cutting down the file, eg by commenting out chunks of it, and from that determine which line is causing the problem.

Hi @delsim , thank you so much the guidance.

I was able to resolve the issue. I had to make two changes

  1. Add WSGIApplicationGroup %{GLOBAL} in httpd.conf and
  2. Move the application file to a folder and change the import statement to
    from dash_apps import graph_interaction_demo