Categories
django

Finding a Bloody Decent Django Reporting Tool

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 SQL. The 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

Updated (2018-02-23)

Django Model Report

I thought 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.

django-report-builder

You can export to xls or csv but there are some issues when translating, displaying and aggregating django native model fields like DurationField

django-report-builder display fields issue

Django-SQL-Explorer

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.

I created the frontend using django forms and custom javascript – ie. I had to do a bit of coding (but not from scratch I made use of django forms and jquery).

customer-report-formGenerating of the HTML, CSV, PDF and excel report was done with the help of pandas and easy pdf.