Dashboard API

This page describes the API of the dashboard and dashboard modules.

Dashboard

class jet.dashboard.dashboard.Dashboard(context, **kwargs)

Base dashboard class. All custom dashboards should inherit it.

available_children = None

Dashboard Modules (widgets) that user can add to dashboard at any time

List of dashboard module classes

children = None

Dashboard Modules (widgets) that dashboard is filled with, when the user open it for the first time

List of dashboard module instances

columns = 2

Number of columns in which widgets can be placed

init_with_context(context)

Override this method to fill your custom Dashboard class with widgets. You should add your widgets to children and available_children attributes.

Usage example:

from django.utils.translation import ugettext_lazy as _
from jet.dashboard import modules
from jet.dashboard.dashboard import Dashboard, AppIndexDashboard


class CustomIndexDashboard(Dashboard):
    columns = 3

    def init_with_context(self, context):
        self.available_children.append(modules.LinkList)
        self.children.append(modules.LinkList(
            _('Support'),
            children=[
                {
                    'title': _('Django documentation'),
                    'url': 'http://docs.djangoproject.com/',
                    'external': True,
                },
                {
                    'title': _('Django "django-users" mailing list'),
                    'url': 'http://groups.google.com/group/django-users',
                    'external': True,
                },
                {
                    'title': _('Django irc channel'),
                    'url': 'irc://irc.freenode.net/django',
                    'external': True,
                },
            ],
            column=0,
            order=0
        ))

DashboardModule

class jet.dashboard.modules.DashboardModule(title=None, model=None, context=None, **kwargs)

Base dashboard module class. All dashboard modules (widgets) should inherit it.

ajax_load = False

A boolean field which specify if widget should be rendered on dashboard page load or fetched later via AJAX.

child_form = None

A django.forms.Form class which may contain custom widget child settings, if it has any. Not required.

child_name = None

Child name that will be displayed when editing module contents. Required if child_form set.

child_name_plural = None

Same as child name, but plural.

collapsible = True

Specify if module can be collapsed.

contrast = False

A boolean field which makes widget ui color contrast.

deletable = True

Specify if module can be deleted.

draggable = True

Specify if module can be draggable or has static position.

init_with_context(context)

Allows you to load data and initialize module’s state.

load_settings(settings)

Should be implemented to restore saved in database settings. Required if you have custom settings.

post_content = None

HTML content that will be displayed after widget content.

pre_content = None

HTML content that will be displayed before widget content.

settings_dict()

Should be implemented to save settings to database. This method should return dict which will be serialized using json. Required if you have custom settings.

settings_form = None

A django.forms.Form class which may contain custom widget settings. Not required.

store_children()

Specify if children field should be saved to database.

style = False

Optional style attributes which will be applied to widget content container.

template = 'jet.dashboard/module.html'

Path to widget’s template. There is no need to extend such templates from any base templates.

title = ''

Default widget title that will be displayed for widget in the dashboard. User can change it later for every widget.

title_url = None

Specify title url. None if title shouldn’t be clickable.