Django Admin Tools Stats Documentation!

Date:May 22, 2017
Keywords:django, python, plot, graph, nvd3, d3, dashboard
Author:Arezqui Belaid
Description:Django-admin-tools-stats is a Django admin module that allow you to create easily charts on your dashboard based on specific models and criterias.



Date:May 22, 2017
Keywords:django, python, plot, graph, nvd3, d3, dashboard
Author:Arezqui Belaid

Django-admin-tools-stats is a Django admin module that allows you to easily create charts on your dashboard based on specific models and criterias.

It will query your models and provide reporting and statistics graphs, simple to read and display on your Dashboard.

Django-admin-tools-stats is an open source project written in Python and using the Django Framework.


Django-admin-tools-stats is a Django application which powers dashboard modules with customer statistics and charts.

The goal of this project is to quickly interrogate your model data to provide reports and statistics graphs which are simple to read and can be used on a Dashboard.



Install, upgrade and uninstall with these commands:

$ sudo pip install django-admin-tools-stats
$ sudo pip install --upgrade django-admin-tools-stats
$ sudo pip uninstall django-admin-tools-stats

Or if you don’t have pip:

$ sudo easy_install django-admin-tools-stats


These tools have been created to improve the django-admin-tools :

With Django-admin-tools you will be able to create and include charts on your dashboard and monitor your data, for instance you can easily monitor new users signing up each day, or new campaigns created per week.

Django-admin-tools also allow you to display a button ‘Select’ that will behave as a filter on the model data.


Development of django-admin-tools-stats takes place on Github:

Bug tracker:

Source download

The source code is currently available on github. Fork away!

Available also on PyPi :


Find the project documentation :


Django-admin-tools-stats was inspired by django-admin-user-stats :


Copyright (c) 2011-2014 Arezqui Belaid <>

Django-nvd3 is licensed under MIT, see MIT-LICENSE.txt.

Installation overview

Install requirements

To get started with Django-admin-tools-stats you must have the following installed:

  • Django Framework >= 1.4 (Python based Web framework)
  • python-dateutil >= 1.5 (Extensions to the standard datetime module)
  • django-admin-tools (Collection of tools for Django administration)
  • django-cache-utils (To provide utilities for making cache-related work easier)
  • django-jsonfield >= 0.6 (Reusable Django field that can use inside models)
  • django-nvd3 >= 0.5.0 (Django wrapper for nvd3 - It’s time for beautiful charts)
  • python-memcached >= 1.47 (Python based API for communicating with the memcached

distributed memory object cache daemon)

Use PIP to install the dependencies listed in the requirments file,:

$ pip install -r requirements.txt


  • Configure django-admin-tools, refer to the documentation of

  • Add admin_tools_stats & django_nvd3 into INSTALLED_APPS in

  • Add the following code to your file

    from admin_tools_stats.modules import DashboardCharts, get_active_graph
    # append an app list module for "Country_prefix"
        _('Dashboard Stats Settings'),
        models=('admin_tools_stats.*', ),
    # Copy following code into your custom dashboard
    # append following code after recent actions module or
    # a link list module for "quick links"
    graph_list = get_active_graph()
    for i in graph_list:
        kwargs = {}
        kwargs['graph_key'] = i.graph_key
        kwargs['require_chart_jscss'] = False
        if context['request'].POST.get('select_box_' + i.graph_key):
            kwargs['select_box_' + i.graph_key] = context['request'].POST['select_box_' + i.graph_key]
  • To create the tables needed by Django-admin-tools-stats, run the following command:

    $ python syncdb
  • Open admin panel, configure Dashboard Stats Criteria & Dashboard Stats respectively

Developer Documentation



To fully understand this project, developers will need to have an advanced knowledge of:

Objects Description


To configure criteria for dashboard graphs


  • criteria_name - Unique word .
  • criteria_fix_mapping - JSON data key-value pairs.
  • dynamic_criteria_field_name - Dynamic criteria field.
  • criteria_dynamic_mapping - JSON data key-value pairs.
  • created_date - record created date.
  • updated_date - record updated date.

Name of DB table: dash_stats_criteria


To configure graphs for dashboard


  • graph_key - unique graph name.
  • graph_title - graph title.
  • model_app_name - App name of model.
  • model_name - model name.
  • date_field_name - Date field of model_name.
  • criteria - many-to-many relationship.
  • is_visible - enable/disable.
  • created_date - record created date.
  • updated_date - record updated date.

Name of DB table: dashboard_stats

Django-admin-tools-stats Modules


Dashboard module with user registration charts. Default values are best suited for 2-column dashboard layouts.

def get_registrations(self, interval, days, graph_key, select_box_value):
Returns an array with new users count per interval.
def prepare_template_data(self, data, graph_key, select_box_value):
Prepares data for template (passed as module attributes)


Group module with 3 default dashboard charts

Test Case Descriptions

How to run tests

1. Run full test suite:

$ python test --verbosity=2

2. Run AdminToolsStatsAdminInterfaceTestCase:

$ python test admin_tools_stats.AdminToolsStatsAdminInterfaceTestCase --verbosity=2

Test Case


Test cases for django-admin-tools-stats Admin Interface.

Indices and tables