Building Custom Dashboards in Django with django-dashing

Blake Bradford Avatar

·

Building Custom Dashboards in Django with django-dashing

dashboard screenshot

Are you looking for a way to visualize interesting data about your Django project? Look no further, because django-dashing is here to help. Django-dashing is a customizable, modular dashboard application framework for Django that enables you to create visually appealing and interactive dashboards.

Prerequisites

Before you get started with django-dashing, make sure you have the following prerequisites installed:

  • Django 1.5 or higher
  • Django Compressor (optional)

Key Concepts

Django-dashing offers some key concepts that make it a powerful tool for creating dashboards:

  1. Use premade widgets or create your own: Django-dashing provides a wide range of pre-built widgets that you can use out of the box. You can also create your own widgets using CSS, HTML, and JavaScript to customize the look and feel of your dashboard.

  2. Use the API to push data: The framework provides an API that allows you to push data to your dashboards in real-time. This means that you can update your dashboard dynamically as data changes, providing an up-to-date view of your project’s metrics.

  3. Drag & Drop interface: Django-dashing offers a user-friendly drag and drop interface for rearranging widgets on your dashboard. This allows you to easily organize and customize the layout of your dashboard to suit your needs.

Installation

To install django-dashing, follow these steps:

  1. Install the latest stable version from PyPi using pip:

$ pip install django-dashing

  1. Add ‘dashing’ to your project’s INSTALLED_APPS settings:

python
INSTALLED_APPS = (
...
'dashing',
)

  1. Include the Django-dashing dashboard URLconf in your project’s urls.py file:

python
from dashing.utils import router
...
url(r'^dashboard/', include(router.urls)),

  1. Start the development server and visit http://127.0.0.1:8000/dashboard/ to view the dummy dashboard.

Quick Start

To create your own custom dashboard and retrieve data from Django, follow these steps:

  1. Create a Django dashboard application with a widgets.py file.

  2. Create your widget by extending from NumberWidget, ListWidget, GraphWidget, or simply Widget (from dashing.widgets).

  3. Register your widget in urls.py:

“`python
from django.conf.urls import url, include
from dashing.utils import router

from project.dashboard.widgets import CustomWidget

router.register(CustomWidget, ‘custom_widget’)

urlpatterns = [
url(r’^dashboard/’, include(router.urls)),
]
“`

  1. Create a dashing-config.js file in your static directory to define your widget and retrieve the data:

javascript
var myDashboard = new Dashboard();
myDashboard.addWidget('customWidget', 'Number', {
getData: function () {
var self = this;
Dashing.utils.get('custom_widget', function(data) {
$.extend(self.scope, data);
});
},
interval: 3000
});

Note: You can also customize the location of the config file by creating a dashing/dashboard.html file in your TEMPLATE_DIRS and specifying the path to your JavaScript config file.

Testing

To run tests for django-dashing, follow these steps:

  1. Install the required dependencies:

$ npm install
$ pip install -r requirements.txt

  1. Run the tests:

$ npm test

Links

Now that you have a comprehensive overview of django-dashing and how to build custom dashboards, you can start visualizing and analyzing your project’s data in a unique and interactive way. Happy dashboarding!

References:
django-dashing repository
talpor GitHub profile

Leave a Reply

Your email address will not be published. Required fields are marked *