Skip to main content

Dash Manager

Dash Manager is an easy-to-use device that allows you to combine multiple Dash applications on a single Flask server. A layout wrapper is also adding for each application into which common elements, such as the navigation bar, can be encoded.

Simple Example

from dash_manager import DashManager, BaseView
from dash import Dash, html


manager = DashManager(template_mode='bootstrap') # or mantine


# Pages
page = Dash(name='First Dashboard')
page.layout = lambda: html.Div('This is First Dashboard')

page2 = Dash(name='Second Dashboard', url_base_pathname='/two/')
page2.layout = lambda: html.Div('This is Second Dashboard')

page3 = Dash(name='Third Dashboard', url_base_pathname='/three/')
page3.layout = lambda: html.Div('This is Third Dashboard')


# Views
manager.add_view(BaseView(page, category='Dropdown'))
manager.add_view(BaseView(page2, category='Dropdown'))
manager.add_view(BaseView(page3))

# Run app
manager.run(debug=True)

Instalation

Dash-manager is published as a Python package and can be installed with pip, ideally by using a virtual environment. Open up a terminal and install dash-manager with:

pip install dash-manager

This will automatically install compatible versions of all dependencies: Flask, Dash, Dash Bootstrap & Dash Mantine. Dash manager always strives to support the latest versions, so there's no need to install those packages separately.

Creating your app

After you've installed Dash Manager, you can create a recommended application structure. Go to the directory where you want your project to be located and enter:

dash_manager new *

This will create the following structure, where in each file there will be detailed descriptions:

.
├─ assets/
├─ webApp/
│  └─ views
│     └─ first_dash
│        └─ __init__.py
│        └─ app.py
│     └─ second_dash
│        └─ __init__.py
│        └─ app.py
│     └─ __init__.py
│  └─ __init__.py
│  └─ config.py
│  └─ server.py
└─ wsgi.py

The resulting project is a basic application that can be run via wsgi.py:

python wsgi.py

Protecting

Dash Manager lets you define access control rules on each of your view classes by simply overriding the is_accessible method. How you implement the logic is up to you, but if you were to use a low-level library like Flask-Login, then restricting access could be as simple as:

from dash_manager import BaseView
from flask import redirect, url_for
from flask_login import current_user


class MyView(BaseView):

    def is_accessible(self):
        return current_user and current_user.is_authenticated

    def inaccessible_callback(self, name, **kwargs):
        # redirect to login page if user doesn't have access
        return redirect(url_for('login', next=request.url))

In the navigation menu, components that are not accessible to a particular user will not be displayed for that user. The main drawback is that you still need to implement all of the relevant login, registration, and account management views yourself.

Customization

You can use three built-in themes for your application: Bootstrap, Mantine & Clear. But if you need a completely custom interface: override dash_manager.manager.template.BaseTemplate class.

class MyTemplate(BaseTemplate):
    def navbar(self, menu: list, links: list):
        """
            Override this method to create a custom navigation bar

            Menu is list of dash_manager.manager.menu.MenuView or 
            dash_manager.manager.menu.MenuCategory object
        """
        ...

    def app_container(self, navbar, app_layout, footer):
        """
            Override this method to create a custom container
        """
        ...

    def footer(self):
        """
            Override this method to create a custom footer
        """
        ...

Read more about this here

Grouping Views

When adding a view, specify a value for the category parameter to group related views together in the menu:

manager.add_view(BaseView(page, category='Dropdown'))
manager.add_view(BaseView(page2, category='Dropdown'))

This will create a top-level menu item named ‘Dropdown’, and a drop-down containing links to the two views.

And to add arbitrary buttons to the menu:

btn = dmc.Anchor(
    dmc.ActionIcon(
        DashIconify(
            icon='radix-icons:avatar', width=22
        ),
        variant="outline",
        radius='md',
        size=36,
        color='indigo',
    ), 
    href='/profile', 
    refresh=True)


manager.add_link(btn)

Metadata

Release files for dash-manager 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dash-manager 1.0.1
File Size Uploaded Provenance Actions
dash_manager-1.0.1.tar.gz 17.5 kB Without provenance Details for dash_manager-1.0.1.tar.gz

Release files / dash_manager-1.0.1.tar.gz

Download URL dash_manager-1.0.1.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5a4dfec71782dbc77c41328a52b5be9337ab74a77fdc4fe6c187b8258d036717
BLAKE2b-256 checksum
How to use checksums
24e44133b0b7893a56d02ad10e30fbd289ed34d35683afe363a20a4507446d70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for dash-manager 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page