RamezIssac/django-slick-reporting

Display a report not working for newby to django

gocamiot opened this issue · 8 comments

Afternoon. I am so lost after week of slugging. I think I got quite far. But still cant add an easy report.
I am trying to make a simple report.
I have changed your menu structure.
I have one model addad to mysql database.
If I migrate, migration works perfect, so I know that the database connection works.
models.py
class test_list(models.Model):
DateCaptured = models.DateTimeField(null=True)
DeviceName = models.CharField(max_length=50, null=True)
DeviceModel = models.CharField(max_length=50, null=True)

So reports.py
class TestList(ReportView):
report_title = _("TestList")
report_model = test_list
# report_title = _("No-Group-By Report")
# date_field = "DateCaptured"
date_field = ""
group_by = ""

columns = [
    "DeviceName",
    "DeviceModel",
]

When I click on menu item on left a popup box comes saying
DataTables warning: table id=DataTables_Table_0 - Requested unknown parameter 'DeviceName' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4

Please help. I need to show a list view of some data with basic filter functions soon, and I am stuck.
Jakes

If i run python manage.py collectstatic
I get
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
The only static directory I am seeing is
slick_reporting\static
can i reference that in settings.py?

Man I am going backwards.
Following these steps, i endup with reports no data:

clone the repo

git clone https://github.com/ra-systems/django-slick-reporting.git

create a virtual environment and activate it

python -m venv /path/to/new/virtual/environment
source /path/to/new/virtual/environment/bin/activate

cd django-slick-reporting/demo_proj
pip install -r requirements.txt
python manage.py migrate
python manage.py create_entries
python manage.py runserver

And the following error when i click on some reports:
http://127.0.0.1:8000/group-by-report/?start_date=2023-01-01+00%3A00%3A00&end_date=2023-10-16+18%3A36%3A24
4.2.6
ImproperlyConfigured
date_field or [start_date_field_name and end_date_field_name] must be set for <demo_app.reports.GroupByReport object at 0x0000017FBE6FDC40>

BTW I tried clone repo with those steps three times same result.

Hello Jakes, not at my PC so a brief pointer.
For ReportView you need a date_field but for a ListReportView you can't have a date_field possibly even if set to "".
You probably don't need collectstatic for a localhost setup.
Watch out for groupby with a FKey. Only fields on the FK model can be columns.

Hello @gocamiot
For the Demo:
I suspect that the virtual env you use to test the demo, have django-slick-reporting installed.
You can check that by executing
pip freeze | grep django-slick-reporting
If so , then uninstall it, pip uninstall django-slick-reporting and run the demo.
I just checked the demo app on the repo and it's running fine.

For the empty data
If you see no data, make sure that some data actually exists in the model and are within the date filter (if any) .

Hope this helps

hey @RamezIssac ,

Ok, so clean install, like the steps. And removing django-slick-reporting. Works SPOT on now. Thank you. I will try and do that with my custom reports on your framework. I let you know. Thank you for coming back to me!
Have a blessed day mate.

Watch out for groupby with a FKey. Only fields on the FK model can be columns.

I will digest and try to figure out what you meant here. Thank you. Again much much apreciated.

My own reports now working. Thank you. I will keep you posted. Have a blessed day.