Reporting Quick Start
Developer guide for the Enezaframework reporting engine. Part of the Add Report series.
Table of Contents
- Overview
- Step 1 — Define the Report Class
- Step 2 — Register a URL
- What Happens on the First Request
- Default Parameters
- Related Guides
Overview
A working report needs two things: a class that subclasses one unified
*ReportView base, and a URL entry. Nothing else is required — the framework
supplies the filter form, the data generation, and the template.
You will build: a minimal tabular report that groups sales lines by item and shows a total column.
Step 1 — Define the Report Class
Put report classes in your app's views/reports.py (or any module that
views/__init__.py imports).
# myapp/views/reports.py
from enezareporting.report_base import TabularReportView
from enezareporting.parameters import ParameterSet, DateRangeParam
from myapp.models import SalesLine
class SalesReport(TabularReportView):
report_title = "Sales Report"
report_model = SalesLine
date_field = "date_placed"
group_by = "item_code"
columns = ["item_description", "__total__"]
parameter_spec = ParameterSet(
DateRangeParam(name="date_range", start_field="date_placed"),
)
What each attribute does:
| Attribute | Purpose |
|---|---|
report_model |
The Django model the report reads. |
date_field |
The date field used for date-range filtering. |
group_by |
The field rows are grouped by. |
columns |
Fields, computation field names, or callables to display. |
parameter_spec |
The filter inputs shown to the user. |
Step 2 — Register a URL
# myapp/urls.py
from django.urls import path
from myapp.views.reports import SalesReport
app_name = "myapp"
urlpatterns = [
path("sales-report/", SalesReport.as_view(), name="sales_report"),
]
Then navigate to /myapp/sales-report/. The filter form renders first; submitting it
produces the table.
What Happens on the First Request
sequenceDiagram
actor U as User
participant V as Unified View
participant P as ParameterSet form
participant G as TabularReportGenerator
participant T as report.html
U->>V: GET sales-report
V->>V: read TabularReport metadata from the class
V->>P: build form from parameter_spec
P-->>U: date-range form
U->>V: submit date_range
V->>P: cleaned_data -> Q(date_placed__gte/lte)
V->>G: TabularReportGenerator(report_model, columns, group_by, dates)
G-->>V: {data, columns, metadata, chart_settings}
V->>T: render
T-->>U: sales tableDefault Parameters
Report types ship with a default parameter_spec, and the unified bases inherit it:
TabularReportViewinheritsParameterSet(DateRangeParam(name="date_range"))with nostart_fieldset fromTabularReport(enezareporting/report_types.py:255-257). AddFKFilterParam(and a configuredDateRangeParam) explicitly — the quick start above declares its ownparameter_specfor exactly this reason.DocumentReportViewinheritsParameterSet(DocumentParam(name="document_id"))(report_types.py:221-223).DrillDownReportViewinherits an emptyParameterSet()(report_types.py:363).
See Report Parameters for every parameter type.