RamezIssac / django-slick-reporting

The Reporting Engine for Django. Create dashboards and standalone Reports and Charts.

Home Page:https://django-slick-reporting.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

doc_date

boatpy opened this issue · comments

I cannot use slick-reporting without adding doc_date to my model that i wish to report on. I dont know if this is a bug or intended. It is not referred to in the documentation and this has been arrived at after hours of trying to troubleshoot why doc_date was required.

Experiencing same issue with doc_date. Is doc_date intended or a bug?

Slick-Reporting looks really promising.

Hello @FredrickUghimi @boatpy

For the doc_date, the class needs a base date field to work on... it's called 'doc_date' by default .
But you can certainly use another date fields.

doc_date reference is removed from code base totally.
if date_field is not set, an exception is raised.

It's nice that you're trying Django Slick Reporting again :)

date_field is the name of date field on your report model that you want to use to filter or in a time series. It's mandatory.

My date field name is date. Can I use that?

Yes ! date_field = 'date' should do it :)

  1. A stack trace would be nice so i can debug

  2. I saw couple of issues with dates, they are addressed in the develop branch now.. Pypi release is sometime tomorrow.

  3. Charts should be straight forward

chart_settings = [{ 'type': 'pie', 'data_source': ['__total_quantity__'], 'title_source': ['title'], }]

https://django-slick-reporting.readthedocs.io/en/latest/tour.html#charts
I welcome any clarification you see regarding the documentation

Hello,

Thank you for your response.

  1. I will send a stack trace later today. I am cleaning up my program.

  2. Thank you for your efforts

  3. Do I need to do anything to call up the chart? Because I tried the reporting a stand alone table which was successful apart from the date issue, but saw no chart. Is it because I muted the group_by field (since it keeps spitting out error that I can't understand). Is the group_by supposed to point to a field or table? In the chart settings. Is the 'title_source': 'title', just an arbitrary string or a field? The 'title': _('Total Monthly Sales'),': has an underscore before the open bracket. Is that supposed to be?Because Python is raising an error there. This is confusing:
    data_source': 'total_quantity', Is it point to a normal field or an internal parameter? I used my 'quantity' field.

I think publishing a little workable complete sample would suffice and give clarity.

Best regards.

Re No.3:

For _, this is a Django convention (https://docs.djangoproject.com/en/3.1/topics/i18n/translation/#standard-translation):

from django.utils.translation import ugettext_lazy as _

For the chart:

data_source parameter : this is the name of the field you want to plot.
In case of having a group_by then that's a ReportField ,
In case of no group_by then it's a field on the report model

A Complete Sample example looks like this

from django.db.models import Sum
from .models import SalesLineTransaction

class TotalProductSales(SlickReportView):
    report_model = SalesLineTransaction
    report_title = 'Product Sales'
    date_field = 'date'

    # A foreign key to group the calculation on.
    group_by = 'product'
    # the SalesLineTansaction example model have a foreign key called 'product'

    columns = ['title',
               SlickReportField.create(Sum, 'quantity', name='quantity__sum'),
               SlickReportField.create(Sum, 'value', name='value__sum')
               ]

    chart_settings = [{
        # this chart will plot the quantity sum
        'type': 'pie',
        'data_source': ['quantity__sum'],
        'title_source': ['title'],
    }, {
        # this chart will plot the value sum
        'type': 'pie',
        'data_source': ['value__sum'],
        'title_source': ['title'],
    }, 
]

If you dont have a group and you want to plot a field on the report model you can definitely do so.

Hello Ramez,

Thank you for your explanation and the sample codes. It made things a little clearer for me. I was able to successfully create two different charts. One with the group_by included and the other, a standalone table.

My Observations:

  1. I don't see the quantity being summed up.
  2. The standalone table chart wouldn't display. It says undefined besides the color pallet. The sum values not displaying as well.

Overall things are looking good.

Closing
You can always refer to https://django-slick-reporting.com/ for live examples :)

You can generate a chart on a model not connected to any other model .. that's for sure.
You can also do reports without the group by (like in here https://django-slick-reporting.com/time-series-without-group-by/)

Kind regards.

I think slick-reporting version on heroku is outdated ...

For the chart,

  1. what wrapper & engine are you using, Charts js or highcharts ?
  2. Please locate the developer tools log on the browser, it might gives an insight on what might be wrong

Last but not least

I think adding Models to your sample codes will bring more clarity.

Models of different structure you mean ? Can you further explain ?

Glad to know that finally your project is working :)
Closing this.