Plotly Dash served in Django - dash_bootstrap_components error


I have set up a django site and embedded plotly dash into the urls. This has worked successfully. However, I am now trying to make the site ‘pretty’ and use

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

I receive the below error.

Django version 3.0.4, using settings ‘UPS.settings’
Starting ASGI/Channels version 2.4.0 development server at
Quit the server with CTRL-BREAK.
HTTP GET /test/ 200 [0.13,]
HTTP GET /django_plotly_dash/app/test/ 200 [0.03,]
HTTP GET /django_plotly_dash/app/test/_dash-component-suites/dash_bootstrap_components/_components/dash_bootstrap_components.v0_9_0m1585057943.min.js 302 [0.01,]
Not Found: /static/dash/component/dash_bootstrap_components/_components/dash_bootstrap_components.min.js
HTTP GET /static/dash/component/dash_bootstrap_components/_components/dash_bootstrap_components.min.js 404 [0.02,]
HTTP GET /django_plotly_dash/app/test/_dash-layout 200 [0.05,]
HTTP GET /django_plotly_dash/app/test/_dash-dependencies 200 [0.07,]

  1. I have done pip install dash-bootstrap-components
  2. Configuration options — django-plotly-dash documentation - did all that.
  3. Please note - prior to trying to import dash_bootstrap_components as dbc and then trying to use dbc. whatever - I was able to use plotly dash successfully with 400 lines of code. Only introducing the bootstrap stuff is throwing errors and I have nooooooo idea what to do.

Thank you for your time

1 Like

@avnj take a look at the django-plotly-dash documentation, particularly here which covers the configuration options. Fundamentally, some manipulation is needed to align the parts of a Dash app with routes in Django, particularly those of static assets.

There is also an example using dash-bootstrap-components in the demo part of the source repository.

1 Like

Unfortunately the link you shared is the link I posted.

There seems to be an error using dash_bootstrap_components within Django

I also would like to add the below example copied and pasted works just fine in an IDE on my desktop.

However, that exact code imported into a djangodash app on Django will throw the errors. Django is ignoring the code that pip install dash-bootstrap-components installed.

import dash
import dash_bootstrap_components as dbc
import dash_html_components as html

app = dash.Dash(external_stylesheets=[dbc.themes.BOOTSTRAP])

app.layout = dbc.Navbar(
html.Span(“A”, style={“color”: “red”}),
html.Span(“B”, style={“color”: “green”}),
html.Span(“C”, style={“color”: “blue”}),
dbc.NavItem(dbc.NavLink(“Item 1”, href="#")),
dbc.NavItem(dbc.NavLink(“Item 2”, href="#")),

if name == “main”:

Your problem is that you are trying to set external_stylesheets=[dbc.themes.BOOTSTRAP] - this won’t work. You need to set the add_bootstrap_links flag as per the code link. From the demo:

dd = DjangoDash("BootstrapApplication",

Edit: documentation isn’t clear on this point; have raised an issue in the github project

1 Like


I appreciate your comment. I made the code change. However, I still received 404 errors below.

then I only receive
HTTP GET /test/ 200 [0.08,]
HTTP GET /static/channels/js/websocketbridge.js 404 [0.02,]
HTTP GET /static/channels/js/websocketbridge.js 404 [0.03,]
HTTP GET /django_plotly_dash/app/test/ 200 [0.04,]
HTTP GET /django_plotly_dash/app/test/_dash-component-suites/dash_bootstrap_components/_components/dash_bootstrap_components.v0_9_0m1585057943.min.js 302 [0.01,]
HTTP GET /static/dash/component/dash_bootstrap_components/_components/dash_bootstrap_components.min.js 404 [0.01,]
HTTP GET /django_plotly_dash/app/test/_dash-layout 200 [0.07,]
HTTP GET /django_plotly_dash/app/test/_dash-dependencies 200 [0.08,]

Have you followed all of the configuration steps?

In particular, did you get any errors when running collectstatic, and can you validate that whitenoise is being used to serve static files?

Hi, I appreciate your time and your advice! I thought I did, but maybe not? My settings file is below`

Preformatted text`

Django settings for UPS project.

Generated by 'django-admin startproject' using Django 3.0.4.

For more information on this file, see

For the full list of settings and their values, see

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# Quick-start development settings - unsuitable for production
# See

# SECURITY WARNING: keep the secret key used in production secret!

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True


# Application definition

    # 'whitenoise.runserver_nostatic',#HEREEEEEEEEEEE
    'dpd_static_support', #hereeeeeeee


    'django_plotly_dash.middleware.BaseMiddleware', #hereeeeeeeeeeeeeee
    'whitenoise.middleware.WhiteNoiseMiddleware', #hereeee


        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [

WSGI_APPLICATION = 'UPS.wsgi.application'

# Database

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),

# Password validation

        '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


TIME_ZONE = 'America/New_York'    #hereeeeeeeeeeeeee

USE_I18N = True

USE_L10N = True

USE_TZ = True

ASGI_APPLICATION = 'UPS.routing.application'

    'default': {
        'BACKEND': 'channels_redis.core.RedisChannelLayer',
        'CONFIG': {
            'hosts': [('', 6379),],


# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'
STATIC_ROOT = 'static'
LOGIN_URL = 'login'
#     os.path.join(BASE_DIR, 'static')]   # hereeeeeeeeeeee



    # 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": False,

    # Flag controlling local serving of assets
    "serve_locally": False,



My html is

{% extends “coe/base.html” %}
{% load static %}

{% block content %}

{% load plotly_dash %}

<div class="{% plotly_class name='test' %} card" style="height: 100%; width: 110%">
    {% plotly_app_bootstrap name="test" aspect="16by9"%}
    {% plotly_message_pipe %}

{{ plot1 | safe }} # hereeeeeeeeeeeee

{% endblock content %}

And my python is
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_table
from django_plotly_dash import DjangoDash
import pandas as pd
import dash_bootstrap_components as dbc

external_stylesheets = [‘’]
es = [‘’]

app = DjangoDash(‘test’,
# serve_locally=True,

app.layout = html.Div([

Once again, I have no problem writing regular plotly dash code with callbacks or using DBC outside Django. Once Django gets introduced my app just doesn’t load. This is a config problem.

Thank you so much for your time!!!

As the error you get is a 404 for the bootstrap js file/static/dash/component/dash_bootstrap_components/_components/dash_bootstrap_components.min.js can you check inside your STATIC_ROOT directory to see if it is present?

If it is, then you’ve got an issue with whatever is serving your static files. If you are running the Django debug server, then whitenoise is a good idea (and it can be useful for production depending on your reverse proxy configuration) - see the django-plotly-dash demo for an example of how it is used.

If it is not, then the issue is with the collection of static files. As well as the settings, the demo also has setup scripts that encapsulate the steps taken including collectstatic calls.

It is not there. Can collectstatic does not change that.