Quick Start Guide

This guide will walk you through creating a simple "Hello, World" dashboard to display a list of users.

This guide assumes you have already completed the steps in the Installation guide.

1. Create a dashboards.py File

In one of your Django apps, create a new file named dashboards.py. This is where you will define your dashboards and widgets.

Let's create a simple widget that displays a list of recent users.

# your_app/dashboards.py

from controlcenter import Dashboard, widgets
from django.contrib.auth.models import User

# Create a widget to display a list of users
class UserList(widgets.ItemList):
    # The model to display
    model = User
    # The fields to display in the list
    list_display = ('username', 'email', 'date_joined')

# Create a dashboard
class MyDashboard(Dashboard):
    widgets = (
        UserList, # Add the widget to the dashboard
    )

2. Configure Settings

Now, update your settings.py file to point to the MyDashboard class you just created. The CONTROLCENTER_DASHBOARDS setting is a tuple of dashboard definitions.

Each definition is a tuple containing a unique slug for the dashboard and the Python path to the dashboard class.

# settings.py

INSTALLED_APPS = [
    # ...
    'controlcenter',
    'your_app',
    # ...
]

# A tuple of dashboards
CONTROLCENTER_DASHBOARDS = (
    ('mydashboard', 'your_app.dashboards.MyDashboard'),
)

3. Verify URLs

Ensure your root urls.py includes the controlcenter URLs before the default admin URLs.

# your_project/urls.py

from django.urls import path
from django.contrib import admin
from controlcenter.views import controlcenter

urlpatterns = [
    # The dashboard URL
    path('admin/dashboard/', controlcenter.urls),
    # The default admin URL
    path('admin/', admin.site.urls),
]

4. Visit Your Dashboard

Start your development server, log in to the Django admin, and navigate to /admin/dashboard/mydashboard/.

You should now see your dashboard displaying a list of users.

Congratulations! You've created your first dashboard. Now you can explore more advanced configurations and widgets: