class DynamicModelSalesByCountry(ReportView):
report_title = _("Raw SQL Table / Dynamic Model Sales by Country")
report_description = _("Here we're acting on raw SQL table (table_name='regional_sales_summary'). "
"No Django model is involved — the schema is introspected at runtime."
"Demonstrating it with Pre-computed crosstab, but we can use it with any type of reports")
table_name = "regional_sales_summary"
group_by = "product_name"
crosstab_field = "country"
crosstab_columns = ["total_sales", "total_quantity"]
crosstab_precomputed = True
columns = ["product_name", "__crosstab__"]
chart_settings = [
Chart(
_("Sales by Country"),
Chart.BAR,
data_source=["total_sales"],
title_source=["product_name"],
),
Chart(
_("Sales by Country [Pie]"),
Chart.PIE,
data_source=["total_sales"],
title_source=["product_name"],
),
]