RamezIssac/django-slick-reporting

Templates not working after upgrading to 1.1.0

oaaoaa opened this issue · 10 comments

oaaoaa commented

Reports were rendering just fine till 1.0.2 but not working after upgrading to 1.1.0. I have configured with bootstrap4 and chartsjs. I have been using the default templates of the slick-reporting without any customization (have not even specified any templates in my Report Views).

When I do a view source of the generated html page then I don't see any report data in the source html, whereas all the relevant data appears in view source on version 1.0.2.

From the commit history it appears that there have been some changes and renaming of the rendering framework. Do I need to change any settings after upgrading to 1.1.0? I have not yet changed from SlickReportField to ComputationField. Strangely, I also don't see any warning in my console that SlickReportField is deprecated, even though it is there in the code for 1.1.0.

The screen shots for generated pages in 1.0.2 and 1.1.0 are below:

1.0.2
1 0 2

1.1.0
1 1 0

Hello @oaaoaa

Hmmmm, maybe you need to collect static once again ? Any issues in the Dev Console ?

When I do a view source of the generated html page then I don't see any report data in the source html, whereas all the relevant data appears in view source on version 1.0.2.

The strategy for loading the report was enhanced
Now the report page load in browser , then the report is loaded via an ajax call.This can be very benefecial if the reprot is big, or one need to compute the report results only after a user press the filter button.

The release log for this version: https://github.com/ra-systems/django-slick-reporting/releases/tag/v1.1.0

oaaoaa commented

I am testing it in debug environment and have never had to ever collect static in that environment. Was working just fine w/o any issues with v 1.0.2.

I am getting some errors in the browser dev console. Screenshot of the errors is below. Seems like jQuery has not been properly defined in slick reporting templates. I notice that <script src="https://code.jquery.com/jquery-3.7.0.min.js"></script> is missing from js_resources.html. How do I fix this? While I am on this I notice that you have hardcoded bootstrap5 in base.html. Will that cause any issue as I have put bootstrap4 in settings.py

chrome_dev_console

Hello @oaaoaa

I will add a setting to give the option of adding the jquery url, (or remove it so we use the one already on the using site)
For the bootstrap 5, i believe you can override the slick_reporting/js_resources and remove the links you dont need.

What do you think? any proposed approach ? :-)

oaaoaa commented

i think the best approach is to have a setting to set the base.html, so that the reports page can be embedded in a site. The reports.html should just inherit from this and have all the report related logic in a container. Alternatively, the developer can create the base page and include reports.html inside that web page.

This approach is the safest because you may change the data model etc. of the reports data in the future and generally speaking no developer should be writing the code to render the report as it will require changes in case you change your data model in the future.

I also think that you should not require developers to set anything relating to bootstrap4/5 or crispy_forms. Similarly, there is no benefit to be derived by allowing the developer to specify any js_resources such as jquery or even any css library. Slick Reporting should handle the rendering of the reports completely and just document the data model so that someone can build a custom renderer in case he/she is not happy with the default rendering. Alternatively, you may provide some hooks to customize the default rendering.

oaaoaa commented

What do we do in the meanwhile? Reports are not rendering at all. Should we wait for the next release?

I don't have the option of modifying the slick reporting code in my deployment because I pull slick reporting directly on my cloud based deployment. The only way for me is to make copy of portion of the slick reporting code, make it part of my code, modify it and push it to my cloud based deployment.

I hear you, but also slick reporting would need to offer some defaults. If i dont include any bootstrap, how will the user see the page on their first use ? Maybe offer a minimal base and an example base ?

and for what to do now:
I believe you can just override the js_resources and do what you need there.
Add the jquery version you choose, bootstrap version you require or not, remove the select2 etc etc

oaaoaa commented

How do I override js_resources? Through SLICK_REPORTING_FORM_MEDIA?

I am trying to get slick reporting to work out of the box, and it was working just fine till 1.0.2. Please advise how I can do so in 1.1.0?

I am a little confused as there are settings (and you also require installation of crispy-bootstrap4 or crispy-bootstrap4) the slick reporting documentation asks us to include that point to bootstrap4 but the default templates etc are all pointing to bootstrap5. Are both the versions of bootstrap being used?

For the readme and docs, i will update the instruction to clarify to user to choose their version of bootstrap (or other).

For overriding the js_resources,i mean this https://docs.djangoproject.com/en/4.2/howto/overriding-templates/

Same issue