I have never liked creating reports and custom tables based on filters for end users. I don’t think any developer does.
It feels like a very generic task and can be achieved (more) easily and with greater agility with the use of
group_by does not really exist in
django. It smartly hides that from the developer and rightly so. It also seems that django was never strong on reporting, and was more reporting on news events…
Unfortunately when a client now asks for totals, group bys and custom filtering…django-tables2 just does not cut it anymore. So as a lazy developer, let us find something that can help us from reinventing the wheel and writing so much damn code.
What do I need out of the reporting package?
- Automatic filters – filters of related fields, dates and relevant validation should be created automatically and be customisable
- Fields to show, group by and aggregations should be options when generating the table of report
- Subtotals and totals should show based on the grouped by options selected
- Formats of output should be automatic based on django settings and be able to be overriden
But pictures paints 1000 words, so here are some screenshots of what I am trying to create:
The main report screen:
Available options that update dependent fields and uncheck users not linked to specific projects or clients:
This is what the final “grouped by” report with totals and sub totals looks like:
Django Reporting Packages
These are some of the packages I found. There are some more and a bit more info at djangopackages.com
- Geraldo Reports – Geraldo is a reports engine with its own API, created in Python language to output PDFs and other formats for complex reports
- Django Pivot – A module for pivoting Django Querysets
- Django Advanced Reports – Advanced Reports for Django
- Django On My Desk – A Django app to build reports in a simple way.
- Django-mr-reports – A Django app to make simple, opinionated reports
- django-pandas – Tools for working with pandas in your Django projects
- django-sql-explorer – Easily share data across your company via SQL queries
- django-model-report – django reports integrated with highcharts
- django-report-builder – A GUI for Django ORM
Django Model Report
django-model-report was the white knight but it does not support python3.
It has exactly what I am looking for in a report, check this screenshot (grouped by):
Unfortunately it does not support python 3, so I have to throw it out of the mix.
Django Report Builder
A good offering, works with
python3 but lacks the ability to select from a dropdown when filtering. You need the exact id or name (there is no dropdown) or available options.
You can export to
csv but there are some issues when translating, displaying and aggregating django native model fields like
A decent offering but you need to know SQL well and for me the schema was not showing at all. So it was difficult to guess the table and column names.
What Did I use in the End for my Django Reporting Tool?
At the end of the day, I decided to use pandas via django-pandas. This gave me all the versatility of sql (and more) and also has some helpers to export the dataframe to excel, csv or something similar.