RamezIssac/django-slick-reporting

How to instantiate report to show no results unless at least one filter is selected from dropdown?

JoRSchmidt1995 opened this issue · 4 comments

Hi, dealing with a very large dataset (over 40 million rows) and want to be able to instantiate the web page of any of the SlickReportViews to show an empty table until I select a filter from at least one of the dropdowns (corresponding to foreign keys in my table) so as to only do calculations like time series on a filtered queryset.

Hello ! That would be a nice Option to set on the package.

For now , you can override the get on your view and do something like this

def get(self, request, *args, **kwargs):
    if not request.GET: 
        return self.render_to_response(self.get_context_data())
    return super().get(request, *args, **kwargs)

Thanks! However, i keep getting the "AttributeError: '(my Slickreport view name)' object has no attribute 'form' callback when trying this.

Most likely raised by get_form_crispy_helper on the SlickReportView class .
Override this to check on the existance of the form first because calling the get_crispy_helper

Hello @JoRSchmidt1995

Starting from release https://github.com/ra-systems/django-slick-reporting/releases/tag/v1.1.0
You can auto_load = False to your ReportView and it wont be computed/calculated until the user send an explicit get request.

Hope you find this helpful