Upgrading from 0.2
Version 0.3 is a big update, but your insights keep working. Most projects need the four steps below and take about ten minutes. Your collected data is kept.
What changed #
| Area | What changed | Do you need to act? |
|---|---|---|
| Requirements | Python 3.11 to 3.14, Django 5.2, 6.0 or 6.1 | Yes, if you are older |
| Settings | Three renamed, the chart colors replaced by INSIGHTS_THEME |
Yes |
| Database | Two migrations for the insights database |
Yes, one command |
| Collecting | One transaction, a failing insight now makes the command exit with an error | Check your cron or CI |
| Permissions | A permission class without has_permission now denies access |
Check your classes |
| PDF export | Removed, with all its dependencies | Yes, if you used it |
| Dashboard | New design with Basecoat UI, light and dark | Only if you override templates |
| New | Trends, themes with 24 shadcn colors, 8 styles, system checks | No, optional |
Upgrade in four steps #
-
Upgrade the package. You need Python 3.11 to 3.14 and Django 5.2, 6.0 or 6.1 (Django 6 needs Python 3.12+).
pip install -U django-insights -
Rename your settings. The old names are ignored,
manage.py checkwarns while they are still set.Old New INSIGHT_CHARTS_USE_MEDIA_CACHEINSIGHTS_CHARTS_USE_MEDIA_CACHEINSIGHT_MEDIA_CACHE_ROOTINSIGHTS_MEDIA_CACHE_ROOTINSIGHT_DASHBOARD_PERMISSIONSINSIGHTS_DASHBOARD_PERMISSIONSINSIGHTS_CHART_LIGHT_PRIMARY_COLOR,INSIGHTS_CHART_DARK_PRIMARY_COLORINSIGHTS_THEME, see ThemingINSIGHTS_THEME = "blue" # a shadcn theme name, or {"accent": "#ec4899"}INSIGHTS_APP_NAME,INSIGHTS_CHART_DPIandINSIGHTS_DEFAULT_THEMEare unchanged. -
Migrate the insights database. Two migrations, your data is kept.
python manage.py migrate insights --database=insights -
Collect once and check.
python manage.py collect_insights # exit code 0 python manage.py check # no insights warnings
That is it for most projects. Read on for the changes that can affect you.
Things to check #
A class in INSIGHTS_DASHBOARD_PERMISSIONS without a has_permission(request) method used to be skipped, which granted access. It now raises ImproperlyConfigured and the dashboard denies access. Check that every class you list has the method and returns True for the people who should get in.
collect_insights now runs in one transaction. When an insight raises, it is logged and reported, the others still run, and the command exits with an error such as 3 of 14 insights failed. A monitor that watches the exit code will start to report them.
Nothing replaces it. Remove links to insights:insight_pdf and insights:insight_pdf_test, and the [pdf] extra from your requirements. weasyprint, django-weasyprint and PyMuPDF are no longer used, and no system libraries (Pango and friends) are needed.
Dashboard URLs use a stable id per app, derived from the module path. Bookmarks of /app/<uuid>/ from 0.2 stop working once, collect again and use the new links.
What is new #
- Trends on counters and gauges: a small line and the change against the previous period, see Trend.
- Themes: pick a Basecoat style and shadcn colors, shared by the dashboard and the charts, see Theming.
- System checks:
manage.py checkwarns about a missing insights database, a wrong setting and more, see System checks. - Stable collecting: one transaction, per-insight errors, no output when it is not a terminal.
- A pytest plugin that loads by itself, see Testing insights.
More details #
Settings behavior
- Settings are read when they are used, so
override_settingsworks. Unknown names raiseAttributeError. INSIGHTS_CHARTS_USE_MEDIA_CACHE = TruerequiresINSIGHTS_MEDIA_CACHE_ROOT(insights.W003).- System checks are warnings only (
insights.W001toW012), they never stop the project from starting.django_insights.database.check_settings()is removed, runmanage.py check.
The database migrations
0002: labels are unique per app (two apps can both havecount_users),Counter.valueis a big integer, explicit ordering. The unused histogram type, theExecutionDeltamodel andGauge.gauge()are removed.0003: atrendcolumn for counters and gauges.
The insights database is a cache of your data, so you can also delete it, migrate it again and run collect_insights.
Collecting from code
metrics.collect()returns the list of failures. It raisesInsightsError(fromdjango_insights.exceptions) when an insight saves duplicates, it no longer prints and callsexit().- The progress bar is hidden when the output is not a terminal.
- The chart cache only deletes cached
*-*-*.pngfiles, it no longer wipes the whole media cache root.
Templates and static files
Only needed if you override templates or use the template tags yourself.
- The dashboard is rebuilt with Basecoat UI. The templates under
insights/have a new structure (base.html,dashboard.html,app.html,_bucket.html,_stat.html,_empty.html). If you override any, start from the new ones, see Customizing. {% chart bucket %}no longer takes anoverlayargument.{% pdf_chart %}andpdf_availableare removed, and so are theinsights/pdf.htmlandpdf.cssoverrides.- Stylesheets are compiled per Basecoat style, icons are CSS classes and the Geist font is served from the package. Nothing is loaded from a CDN. Run
collectstaticas usual. - The chart font is Geist (was Ubuntu). The library no longer changes matplotlib’s global configuration.
Using the library in code
- The
insightsconsole script is removed (it never worked). barandhbarcharts no longer crash when a category isNone.- Only the names in
__all__ofdjango_insights.metricsanddjango_insights.metrics_typesare public.
Testing with the pytest plugin
- The plugin loads through the
pytest11entry point, you do not need to register it. - The module-level
registry,register_insights_modulesand the injected fixture are removed. If you imported them fromdjango_insights.pytest, use theinsights_queryfixture instead. - Errors inside an
insights.pyare no longer swallowed. Theinsightsmarker is registered, so--strict-markersworks.
Building from source
Only for contributors.
uv buildreplaces flit. The version comes from the latest git tag (setuptools-scm).pnpm install && pnpm buildindjango_insights/packagesrebuilds the dashboard CSS.- ruff replaces black, isort and flake8, and tox runs through uv. Releases are made by pushing a tag.