Report Views
Developer guide for the Enezaframework reporting engine. Part of the Add Report series.
Table of Contents
- Overview
- Unified Report Bases (Recommended)
- How the Report Type Is Resolved
- Legacy Views (Backward Compatible)
- Commonly Used View Attributes
- Type-Specific Context
- Related Guides
Overview
Each unified base in enezareporting.report_base is the single parent for a report type.
It already contains the type metadata, form building, generator dispatch, designer
rendering, query-builder filters, and totals hooks, so report classes inherit exactly one
class.
All unified bases live in enezareporting.report_base; the lower-level view classes remain
in enezareporting.views.
Unified Report Bases (Recommended)
from enezareporting.report_base import TabularReportView
from enezareporting.parameters import ParameterSet, DateRangeParam
from myapp.models import SalesLine
class SalesReport(TabularReportView):
report_model = SalesLine
columns = ["item_description", "__total__"]
parameter_spec = ParameterSet(
DateRangeParam(name="date_range", start_field="date_placed"),
)
Each base automatically:
- Uses the report metadata from the class itself.
- Builds the correct form from
parameter_spec. - Instantiates the matching generator.
- Adds type-specific context (
document_header,drilldown_breadcrumb, and so on). - Applies designer layouts when
design_slugis set and totals whenadd_totals = True.
classDiagram
class BaseReportView
class TabularReportView
class SummaryReportView
class DetailedReportView
class CrosstabReportView
class TimeSeriesReportView
class DrillDownReportView
class DocumentReportView
class BaseDocumentReport
BaseReportView <|-- TabularReportView
BaseReportView <|-- CrosstabReportView
BaseReportView <|-- TimeSeriesReportView
BaseReportView <|-- DrillDownReportView
TabularReportView <|-- SummaryReportView
TabularReportView <|-- DetailedReportView
BaseDocumentReport <|-- DocumentReportViewHow the Report Type Is Resolved
Unified bases carry the report type metadata directly, so no MRO scan is needed:
_resolve_report_type() returns the report class itself.
ReportEngineView remains available for advanced and legacy use. Its resolution order is:
- If
report_type_classis set, return it. - If the view class itself subclasses
ReportTypeand has aparameter_spec, return it. - Otherwise scan the MRO for the first base with a
parameter_spec.
Set report_type_class on ReportEngineView when you want to reuse one view class for
several report types:
class GenericReportView(ReportEngineView):
report_type_class = SalesReport
Legacy Views (Backward Compatible)
These classes continue to work:
| View | Use case |
|---|---|
ReportView |
Standard report with an inline form. |
ModalReportView |
Report with a right-side modal filter. |
ListReportView |
Flat list view (no aggregation). |
ReportViewBase |
Bare base class (customize everything). |
ReportEngineView |
Low-level view for report_type_class or custom composition. |
Combining a pure report type with ReportEngineView still works but is deprecated and
emits a DeprecationWarning; inherit the matching *ReportView base instead.
The legacy ReportView family builds its forms with report_form_factory() and uses
report_generator_class (default ReportGenerator) rather than a unified report base.
Commonly Used View Attributes
These are defined on ReportViewBase and inherited by every unified base
(enezareporting/views.py). Defaults shown are the actual defaults.
| Attribute | Default | Description |
|---|---|---|
report_title |
"" (falls back to class name) |
Display title. |
report_slug |
None |
URL/identifier slug. |
report_description |
"" |
Optional description. |
template_name |
"eneza_reporting/report.html" |
Template path. |
use_modal_filter |
False |
Use a right-side modal instead of an inline form. |
auto_load |
True |
Auto-load data on page open. |
chart_settings |
None |
List of chart configs. |
chart_engine |
"" |
Chart engine override. |
company_name |
"Enezatech Digital Solutions" |
Company name for the print header. |
currency |
"KES" |
Currency code for the print header. |
report_generator_class |
ReportGenerator |
Generator used by legacy views. |
base_model |
None |
Base model for schema-derived reports. |
design_slug |
None |
Designer layout slug; designer rendering is built into every unified base. |
add_totals |
False |
Append a totals row to tabular results. |
totals_group_column |
None |
Column that receives the totals label. |
line_total_fields |
[] |
Result columns summed into the totals row. |
default_order_by |
"" |
Default result ordering. |
use_query_builder |
False |
Enable the query-builder filter UI. |
export_actions |
None |
Extra export actions. |
Type-Specific Context
The report view's get_context_data() injects context depending on the resolved type:
| Type | Context keys |
|---|---|
DocumentReportView |
document_header, document_lines, document_totals, is_document_report |
DrillDownReportView |
drilldown_breadcrumb, drilldown_current_level, is_drilldown_report, drilldown_rows |