Tabular, Summary & Detailed Reports
Developer guide for the Enezaframework reporting engine. Part of the Add Report series.
Table of Contents
- Overview
- TabularReportView
- SummaryReportView
- DetailedReportView
- Choosing Between Them
- Related Guides
Overview
TabularReportView is the workhorse report base: grouped, optionally aggregated rows.
SummaryReportView and DetailedReportView are marker subclasses that signal
aggregation-only and no-aggregation modes respectively. All three live in
enezareporting.report_base.
TabularReportView
Standard grouped/aggregated table. Define report_model and columns; set group_by
and the date/pivot extras when needed.
Attributes
| Attribute | Required | Description |
|---|---|---|
report_model |
Yes | Django model for the data source. |
columns |
Yes | Field names, computation field names, or callables. |
group_by |
No | Field name to group rows by. |
date_field |
No | Date field for date-range filtering. |
time_series_pattern |
No | If set, adds per-bucket columns (daily, weekly, monthly, ...). |
crosstab_field |
No | If set, adds pivot columns. |
swap_sign |
No | Swap debit/credit sign handling. |
Example
from enezareporting.report_base import TabularReportView
from enezareporting.parameters import ParameterSet, DateRangeParam, FKFilterParam
from myapp.models import SalesLine
class SalesByCustomer(TabularReportView):
report_title = "Sales by Customer"
report_model = SalesLine
date_field = "date_placed"
group_by = "customer"
columns = ["customer__name", "__total__", "__balance__"]
parameter_spec = ParameterSet(
DateRangeParam(name="date_range", start_field="date_placed"),
FKFilterParam(name="product", model_field="product"),
)
A bare
TabularReportViewinherits a defaultParameterSet(DateRangeParam(name="date_range"))with nostart_fieldfromTabularReport(enezareporting/report_types.py). Add a configuredDateRangeParamand anyFKFilterParamyourself when you want working filters.
SummaryReportView
SummaryReportView is a marker subclass of TabularReportView that signals
aggregation-only mode — group totals with no detail rows.
from enezareporting.report_base import SummaryReportView
from myapp.models import SalesLine
class SalesSummary(SummaryReportView):
report_title = "Sales Summary"
report_model = SalesLine
group_by = "product"
columns = ["product__name", "__total__"]
DetailedReportView
DetailedReportView signals no-aggregation mode — a list view where every row is shown.
from enezareporting.report_base import DetailedReportView
from myapp.models import SalesLine
class TransactionList(DetailedReportView):
report_title = "Transaction List"
report_model = SalesLine
columns = ["date_placed", "customer__name", "value", "quantity"]
Choosing Between Them
flowchart TD
Q{"What should each row be?"}
Q -->|"One business record"| DET["DetailedReportView<br/>list view, no aggregation"]
Q -->|"One group total"| SUM["SummaryReportView<br/>aggregates only"]
Q -->|"Group subtotals + totals"| TAB["TabularReportView<br/>grouped + aggregates"]All three are rendered by the same view and template; only the generator's aggregation behaviour differs.