Package: django-slick-reporting
Django Slick ReportingA one stop reports engine with batteries included.FeaturesEffortlessly create Simple, Grouped, Time series and Crosstab reports in a handful of code lines.Create Chart(s) for your reports with a single line of code.Create Custom complex Calculation.Optimized for speed.Easily extendable.InstallationUse the package managerpipto install django-slick-reporting.pip install django-slick-reportingUsageSo we have a modelSalesTransactionwhich contains typical data about a sale.
We can extract different kinds of information for that model.Let’s start by a “Group by” report. This will generate a report how much quantity and value was each product sold within a certain time.# in views.pyfromdjango.db.modelsimportSumfromslick_reporting.viewsimportReportView,Chartfromslick_reporting.fieldsimportComputationFieldfrom.modelsimportMySalesItemsclassTotalProductSales(ReportView):report_model=SalesTransactiondate_field="date"group_by="product"columns=["name",ComputationField.create(Sum,"quantity",verbose_name="Total quantity sold",is_summable=False),ComputationField.create(Sum,"value",name="sum__value",verbose_name="Total Value sold $"),]chart_settings=[Chart("Total sold $",Chart.BAR,data_source=["sum__value"],title_source=["name"],),Chart("Total sold $ [PIE]",Chart.PIE,data_source=["sum__value"],title_source=["name"],),]# then, in urls.pypath("total-sales-report",TotalProductSales.as_view())With this code, you will get something like this:Time SeriesA Time series report is a report that is generated for a periods of time.
The period can be daily, weekly, monthly, yearly or custom. Calculations will be performed for each period in the time series.Example: How much was sold in value for each product monthly within a date period ?# in views.pyfromslick_reporting.viewsimportReportViewfromslick_reporting.fieldsimportComputationFieldfrom.modelsimportSalesTransactionclassMonthlyProductSales(ReportView):report_model=SalesTransactiondate_field="date"group_by="product"columns=["name","sku"]time_series_pattern="monthly"# or "yearly" , "weekly" , "daily" , others and custom patternstime_series_columns=[ComputationField.create(Sum,"value",verbose_name=_("Sales Value"),name="value")# what will be calculated for each month]chart_settings=[Chart(_("Total Sales Monthly"),Chart.PIE,data_source=["value"],title_source=["name"],plot_total=True,),Chart("Total Sales [Area chart]",Chart.AREA,data_source=["value"],title_source=["name"],plot_total=False,),]Cross TabUse crosstab reports, also known as matrix reports, to show the relationships between three or more query items.
Crosstab reports show data in rows and columns with information summarized at the intersection points.# in views.pyfromslick_reporting.viewsimportReportViewfromslick_reporting.fieldsimportComputationFieldfrom.modelsimportMySalesItemsclassMyCrosstabReport(ReportView):crosstab_field="client"crosstab_ids=[1,2,3]crosstab_columns=[ComputationField.create(Sum,"value",verbose_name=_("Value for")),]crosstab_compute_remainder=Truecolumns=["some_optional_field",# You can customize where the crosstab columns are displayed in relation to the other columns"__crosstab__",# This is the same as the Same as the calculation in the crosstab, but this one will be on the whole set. IE total valueComputationField.create(Sum,"value",verbose_name=_("Total Value")),]Low levelThe view is a wrapper over theReportGeneratorclass, which is the core of the reporting engine.
You can interact with theReportGeneratorusing same syntax as used with theReportView.fromslick_reporting.generatorimportReportGeneratorfrom.modelsimportMySalesModelclassMyReport(ReportGenerator):report_model=MySalesModelgroup_by="product"columns=["title","__total__"]# ORmy_report=ReportGenerator(report_model=MySalesModel,group_by="product",columns=["title","__total__"])my_report.get_report_data()# -> [{'title':'Product 1', '__total__: 56}, {'title':'Product 2', '__total__: 43}, ]This is just a scratch of what you can do and customize.Demo siteAvailable onDjango Slick ReportingYou can also use locally#clonetherepogit clone https://github.com/ra-systems/django-slick-reporting.git#createavirtualenvironmentandactivateitpython -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 runserverthecreate_entriescommand will generate data for the demo appDocumentationAvailable onRead The DocsYou can run documentation locally<activate your virtual environment>
cd docs
pip install -r requirements.txt
sphinx-build -b html source buildRoad AheadContinue on enriching the demo projectAdd the dashboard capabilitiesRunning testsCreate a virtual environment (maybe withvirtual slick_reports_test), activate it; Then ,$gitclonegit+git@github.com:ra-systems/django-slick-reporting.git$cdtests$python-mpipinstall-e..$pythonruntests.py#OrforCoveragereport$coveragerun--include=../*runtests.py[-k]$coveragehtmlSupport & ContributingPlease consider star the project to keep an eye on it. Your PRs, reviews are most welcome and needed.We honor the well formulatedDjango’s guidelinesto serve as contribution guide here too.AuthorsRamez Ashraf-Initial work-RamezIssacCross ReferenceIf you like this package, chances are you may like those packages too!Django Tabular PermissionsDisplay Django permissions in a HTML table that is translatable and easy customized.Django ERP FrameworkA framework to build business solutions with ease.If you find this project useful or promising , You can support us by a github ⭐