Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/RamezIssac/django-slick-reporting
The Reporting Engine for Django. Create dashboards and standalone Reports and Charts.
https://github.com/RamezIssac/django-slick-reporting
analysis analytics charting charts customisable django easy-to-use pivot-tables python reporting time-series
Last synced: about 2 months ago
JSON representation
The Reporting Engine for Django. Create dashboards and standalone Reports and Charts.
- Host: GitHub
- URL: https://github.com/RamezIssac/django-slick-reporting
- Owner: RamezIssac
- License: bsd-3-clause
- Created: 2020-04-21T08:07:28.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-08-20T12:48:43.000Z (4 months ago)
- Last Synced: 2024-09-17T14:22:11.178Z (3 months ago)
- Topics: analysis, analytics, charting, charts, customisable, django, easy-to-use, pivot-tables, python, reporting, time-series
- Language: Python
- Homepage: https://django-slick-reporting.com/
- Size: 726 KB
- Stars: 548
- Watchers: 19
- Forks: 44
- Open Issues: 21
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
.. image:: https://img.shields.io/pypi/v/django-slick-reporting.svg
:target: https://pypi.org/project/django-slick-reporting.. image:: https://img.shields.io/pypi/pyversions/django-slick-reporting.svg
:target: https://pypi.org/project/django-slick-reporting.. image:: https://img.shields.io/readthedocs/django-slick-reporting
:target: https://django-slick-reporting.readthedocs.io/.. image:: https://api.travis-ci.com/ra-systems/django-slick-reporting.svg?branch=master
:target: https://app.travis-ci.com/github/ra-systems/django-slick-reporting.. image:: https://img.shields.io/codecov/c/github/ra-systems/django-slick-reporting
:target: https://codecov.io/gh/ra-systems/django-slick-reportingDjango Slick Reporting
======================A one stop reports engine with batteries included.
Features
--------- Effortlessly 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.Installation
------------Use the package manager `pip `_ to install django-slick-reporting.
.. code-block:: console
pip install django-slick-reporting
Usage
-----So we have a model `SalesTransaction` which 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.
.. code-block:: python
# in views.py
from django.db.models import Sum
from slick_reporting.views import ReportView, Chart
from slick_reporting.fields import ComputationField
from .models import MySalesItemsclass TotalProductSales(ReportView):
report_model = SalesTransaction
date_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.py
path("total-sales-report", TotalProductSales.as_view())With this code, you will get something like this:
.. image:: https://i.ibb.co/SvxTM23/Selection-294.png
:target: https://i.ibb.co/SvxTM23/Selection-294.png
:alt: Shipped in View PageTime Series
-----------A 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 ?
.. code-block:: python
# in views.py
from slick_reporting.views import ReportView
from slick_reporting.fields import ComputationField
from .models import SalesTransactionclass MonthlyProductSales(ReportView):
report_model = SalesTransaction
date_field = "date"
group_by = "product"
columns = ["name", "sku"]time_series_pattern = "monthly"
# or "yearly" , "weekly" , "daily" , others and custom patterns
time_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,
),
].. image:: https://github.com/ra-systems/django-slick-reporting/blob/develop/docs/source/topics/_static/timeseries.png?raw=true
:alt: Time Series Report
:align: centerCross Tab
---------
Use 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... code-block:: python
# in views.py
from slick_reporting.views import ReportView
from slick_reporting.fields import ComputationField
from .models import MySalesItemsclass MyCrosstabReport(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 value
ComputationField.create(Sum, "value", verbose_name=_("Total Value")),
].. image:: https://github.com/ra-systems/django-slick-reporting/blob/develop/docs/source/topics/_static/crosstab.png?raw=true
:alt: Homepage
:align: centerLow level
---------The view is a wrapper over the `ReportGenerator` class, which is the core of the reporting engine.
You can interact with the `ReportGenerator` using same syntax as used with the `ReportView` ... code-block:: python
from slick_reporting.generator import ReportGenerator
from .models import MySalesModelclass MyReport(ReportGenerator):
report_model = MySalesModel
group_by = "product"
columns = ["title", "__total__"]# OR
my_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 site
---------Available on `Django Slick Reporting `_
You can also use locally
.. code-block:: console
# 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/activatecd django-slick-reporting/demo_proj
pip install -r requirements.txt
python manage.py migrate
python manage.py create_entries
python manage.py runserverthe ``create_entries`` command will generate data for the demo app
Documentation
-------------Available on `Read The Docs `_
You can run documentation locally
.. code-block:: console
cd docs
pip install -r requirements.txt
sphinx-build -b html source buildRoad Ahead
----------* Continue on enriching the demo project
* Add the dashboard capabilitiesRunning tests
-----------------
Create a virtual environment (maybe with `virtual slick_reports_test`), activate it; Then ,
.. code-block:: console
$ git clone [email protected]:ra-systems/django-slick-reporting.git
$ cd tests
$ python -m pip install -e ..$ python runtests.py
# Or for Coverage report
$ coverage run --include=../* runtests.py [-k]
$ coverage htmlSupport & Contributing
----------------------Please consider star the project to keep an eye on it. Your PRs, reviews are most welcome and needed.
We honor the well formulated `Django's guidelines `_ to serve as contribution guide here too.
Authors
--------* **Ramez Ashraf** - *Initial work* - `RamezIssac `_
Cross Reference
---------------If you like this package, chances are you may like those packages too!
`Django Tabular Permissions `_ Display Django permissions in a HTML table that is translatable and easy customized.
`Django ERP Framework `_ A framework to build business solutions with ease.
If you find this project useful or promising , You can support us by a github ⭐