Skip to main content

django-admin-charts - Easily configurable charts statistics for `django-admin` and `django-admin-tools`

Project description

Django admin charts


Easily configurable charts statistics for django-admin and django-admin-tools.

Documentation: Latest Version Downloads Supported Python versions License

Create beautiful configurable charts from your models and display them on the django-admin index page or on django-admin-tools dashboard. The charts are based on models and criterias defined through admin interface and some chart parameters are configurable in live view.

This is application is fork of django-admin-tools-stats which has been reworked to display all charts through Ajax and made work with plain django-admin. The django-admin-tools are supported but not needed.


  • Django>=2.0

  • Python>3.6

  • PostgreSQL (MySQL is experimental, other databases probably not working but PRs are welcome)

  • simplejson for charts based on DecimalField values


Install django-admin-charts with these commands:

$ pip install django-admin-charts

Basic setup for django-admin

Add admin_tools_stats (the Django admin charts application) & django_nvd3 into INSTALLED_APPS in

    'admin_tools_stats',  # this must be BEFORE 'admin_tools' and 'django.contrib.admin'

Register chart views in your

from django.urls import include, path
urlpatterns = [
    path('admin_tools_stats/', include('admin_tools_stats.urls')),

Ensure, you have default cache set up:

Run migrations:

$ python migrate

Open Django admin root and add your Dashboard Stats configuration:

Then the charts will appear on the root of Django admin page as well as on analytics page (/admin_tools_stats/analytics/).

Special configurations

Update from django-admin-tools-stats

Uninstall django-admin-tools-stats.

Follow django-admin-charts installation according to previous section. Especially pay attention to these steps: - Move admin_tools_stats in INSTALLED_APPS before admin_tools and django.contrib.admin. - Configure

Change DashboardCharts to DashboardChart in dashboard definition (this is recomended even if dummy class is left for compatibility reasons).

Check any overridden template from admin_tools_stats or DashboardChart(s) class that might interfere with the changes.

Configure javascript libraries

By default the nvd3/d3 libraries are taken from unpkg. If you want to install those libraries on your own, you can set their path by following settings:

ADMIN_CHARTS_NVD3_JS_PATH = 'bow/nvd3/build/nv.d3.js'
ADMIN_CHARTS_NVD3_CSS_PATH = 'bow/nvd3/build/nv.d3.css'
ADMIN_CHARTS_D3_JS_PATH = 'bow/d3/d3.js'

The settings can accept either full path (with http…) or there can be static file path. Note that versions nvd3==1.8.6 and d3==3.3.13 are the only tested to be working.

Installation of javascript libraries with django-bower

Add django-bower to INSTALLED_APPS in


Add the following properties to you file:

# Specifie path to components root (you need to use absolute path)
BOWER_COMPONENTS_ROOT = os.path.join(PROJECT_ROOT, 'components')


Add django-bower finder to your static file finders:


Run the following commands. These will download nvd3.js and its dependencies using bower and throw them in to you static folder for access by your application:

$ python bower_install
$ python collectstatic

Usage with django-admin-tools

Configure admin_tools

Add following code to

from admin_tools_stats.modules import DashboardChart, get_active_graph

# append an app list module
    _('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"
if context['request'].user.has_perm('admin_tools_stats.view_dashboardstats'):
        graph_list = get_active_graph()
        graph_list = []

for i in graph_list:
    kwargs = {}
    kwargs['require_chart_jscss'] = True
    kwargs['graph_key'] = i.graph_key

    for key in context['request'].POST:
        if key.startswith('select_box_'):
            kwargs[key] = context['request'].POST[key]


You may also need to add some includes to your template admin base, see an example on the demo project:


Usage on DB that doesn’t support JSONFields

You can add following line to your settings in order to use JSONField from django-jsonfield instead of native Django JSONField:


This can become handy, when deploying on MySQL<5.7 (Like AWS RDS Aurora)

Running demo

Run following commands:

export DB_ENGINE='sqlite'
pip install -r requirements.txt
python migrate
python loaddata demoproject/fixtures/auth_user.json
python loaddata demoproject/fixtures/test_data.json
python bower install
python runserver

And log in with username admin and password admin to the localhost:8000/admin site.



django-admin-charts is a django based application, the major requirements are:

  • django-jsonfield

  • django-nvd3

  • django-bower

Running tests

Test can be run with:

DB_ENGINE="postgres" coverage run ./ test --keepdb


If you’ve found a bug, add a feature or improve django-admin-charts and think it is useful then please consider contributing. Patches, pull requests or just suggestions are always welcome!

Source code:

Bug tracker:

Debugging charts

For chart data view (/admin_tools_stats/chart_data/payments/) the URL query parameter &debug=True can be added, in order to get Django debug page or Django debug toolbar.


Documentation is available on ‘Read the Docs’:


django-admin-charts is licensed under MIT, see MIT-LICENSE.txt.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-admin-charts-1.3.1.tar.gz (478.4 kB view hashes)

Uploaded Source

Built Distribution

django_admin_charts-1.3.1-py3-none-any.whl (83.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page