This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.
This page outlines how to configure a Django app for deployment to Dash Enterprise. For running and previewing a Django app in a Dash Enterprise workspace, see the Development App page.
Your Django app’s manage.py
file should be in your project’s root directory. To deploy a Django app to Dash Enterprise, you’ll also need to configure your Django project’s urls.py
and settings.py
files.
The Django Admin site is not currently supported for Django apps on Dash Enterprise. To avoid possible issues, remove admin URLs from your project’s main urls.py
file.
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("", include("polls.urls")),
# path('admin/', admin.site.urls),
]
You’ll also need to add the name of the app initialized on Dash Enterprise as part of the URL in urlpatterns
.
See the initializing an app page for more details.
For example, here we initialize an app called my-django-app
:
<img>
And we then add it to paths in our project’s main urls.py
file:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("my-django-app/", include("polls.urls")),
# path('admin/', admin.site.urls),
]
Ensure you have a path in your app that serves content at the root URL (what a user sees when they visit the app at
https://<your-dash-enterprise-server>/<your-app-name>/
)
In order to track viewer analytics of a Django app in Dash Enterprise a health route must be added.
To add a health route:
urls.py
, where BASE_ROUTE
is the base route for the app.from django.http import HttpResponse
def health_check(request):
return HttpResponse(b'ok')
urlpatterns = [
path(BASE_ROUTE+'_django/health/', health_check, name='health'),
]
If your app is called my-demo-app
, this health route would look like this in urlpatterns
:
urlpatterns = [
path('my-demo-app/'+'_django/health/', health_check, name='health'),
]
<script>
document.addEventListener("DOMContentLoaded", function () {
fetch("_django/health/").then((response) => response);
});
<script>
Known Issue: When users visit a Django app URL without a trailing
/
, views are not added.
To configure the settings.py
file:
ALLOWED_HOSTS
. If you access the Dash Enterprise portal at https://example-dash-enterprise-5-hostname.com/portal
, the hostname would be example-dash-enterprise-5-hostname.com
.python
ALLOWED_HOSTS = [
<dash-enterprise-hostname>
]
django.contrib.admin
, django.contrib.auth
, and django.contrib.sessions
from INSTALLED_APPS
. These are currently unsupported on Dash Enterprise.python
INSTALLED_APPS = [
# 'django.contrib.admin', <-- This line should be removed or commented out
# 'django.contrib.auth', <-- This line should be removed or commented out
'django.contrib.contenttypes',
# 'django.contrib.sessions', <-- This line should be removed or commented out
'django.contrib.messages',
'django.contrib.staticfiles',
]
django.contrib.auth.middleware.AuthenticationMiddleware
from MIDDLEWARE
. This is currently unsupported on Dash Enterprise.python
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
# 'django.contrib.auth.middleware.AuthenticationMiddleware', <-- This line should be removed or commented out
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
DEBUG = False
For more details on settings.py
, see the Django documentation.
Describe your app’s Python dependencies in a requirements.txt
file if you want Dash Enterprise to use the pip buildpack, or describe them in an environment.yml
file if you want Dash Enterprise to use the Conda buildpack.
Note that adding both requirements.txt
and environment.yml
to your app currently causes Dash Enterprise to detect only the pip buildpack, so it is not possible to use both sets of features from these files in the same app.
A Procfile
is a required text file that tells Dash Enterprise which processes to run on
startup, like starting your app’s web server, scheduling jobs, and running background processes.
This file is always named Procfile
—with no file extension. It must be placed in your app’s root directory and uses the following format:
<process>: <command>
Django app Procfile example
A basic Procfile for a Django app looks like this.
web: gunicorn <your-django-app>.wsgi
For the Django app above called mysite
, this would look like this:
web: gunicorn mysite.wsgi
For more details on Django with Gunicorn see How to use Django with Gunicorn.
.gitignore
is a text file that determines which files and folders are ignored by Git.
Files listed in the .gitignore
are not copied to the server when you deploy your app.
venv
*.pyc
.DS_Store
.env
An Aptfile
can be used to install system-level packages via the APT package manager. It supports:
.deb
files.If an Aptfile
is included in your project, an apt-get update
is triggered before installing the packages.
Packages from standard APT repositories
Packages from APT repositories might include database drivers that your app requires.
In the following example we are installing unixodbc
and unixodbc-dev
:
unixodbc
unixodbc-dev
Specific .deb files
You can also add links to specific .deb
files to be installed:
<a href="https://downloads.example.com/example.deb">https://downloads.example.com/example.deb</a>
Custom APT repositories
Your Aptfile
can also contain additional APT
repositories:
:repo:deb <a href="https://apt.example.com/">https://apt.example.com/</a> example-distro main
Important: Dash Enterprise requires that custom APT repositories have a TLS/SSL certificate from a globally trusted certificate authority (CA).
To use APT packages in your apps when Dash Enterprise is internet-restricted, you need to specify a custom APT repository that Dash Enterprise has network access to. See an example in
Developing Apps when Dash Enterprise Is Internet-Restricted.