Structure
If you haven’t yet, please check https://django-slick-reporting.com for a quick walk-though with live code examples..
And now, Let’s explore the main components of Django Slick Reporting and what setting you can set on project level.
Components
Report Field: represent a number, a calculation unit, for example: a Sum of a certain field. The report field identifies how the calculation should be done. ResultFields can depend on each other.
Generator: Represent a concrete report structure.If it would group by certain field, do a time series or a cross tab, and which columns (Report Field) to be calculated. It’s also responsible for computing and provides low level access. ie you can get the data in a list of dict/objects
View: Responsible for creating a nice form to filter the report on, pass those filters to the generator class to create the report. It mimic the Generator API. Provide high level access. You can hook it to your urls.py and you’re all set, with the charts.
Charting JS helpers: Django slick Reporting comes with highcharts and Charts js helpers libraries to plot the charts generated by the View
Settings
SLICK_REPORTING_DEFAULT_START_DATE
: Default: the beginning of the current yearSLICK_REPORTING_DEFAULT_END_DATE
: Default: the end of the current year.SLICK_REPORTING_FORM_MEDIA
: Controls the media files required by the search form. Defaults is:
SLICK_REPORTING_FORM_MEDIA = {
'css': {
'all': (
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.css',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css',
)
},
'js': (
'https://code.jquery.com/jquery-3.3.1.slim.min.js',
'https://cdn.datatables.net/v/bs4/dt-1.10.20/datatables.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js',
'https://code.highcharts.com/highcharts.js',
)
}
SLICK_REPORTING_DEFAULT_CHARTS_ENGINE
: Controls the default chart engine used.