class TotalProductSalesByCountry(ReportView):
report_title = _("Product Sales by Country")
report_description = _("Group by using Django's double-underscore traversal (group_by='client__country').")
report_model = SalesTransaction
date_field = "date"
group_by = "client__country" # notice the double underscore
columns = [
"client__country",
ComputationField.create(Sum, "value", name="sum__value", verbose_name="Total Value sold by country $"),
]
chart_settings = [
Chart(
"Total sold by country $",
Chart.PIE, # A Pie Chart
data_source=["sum__value"],
title_source=["client__country"],
),
]