Django Report Tools¶
Report tools aims to take the pain out of putting charts, graphs and tables into your Django projects. It lets you do the following:
- Define your reports using the same syntax as Django forms and models
- Use built-in ‘renderers’ to avoid the hassle of dealing with various charting technologies (currently only the Google Visualization Toolkit is supported)
- Enter chart data in a standardised format
- Build a simple API, allowing for the creation of chart exports or a ‘save to dashboard’ feature.
An example report:
class MyReport(Report):
renderer = GoogleChartsRenderer
pie_chart = charts.PieChart(
title="A nice, simple pie chart",
width=400,
height=300
)
def get_data_for_pie_chart(self):
data = ChartData()
data.add_column("Pony Type")
data.add_column("Population")
data.add_row(["Blue", 20])
data.add_row(["Pink", 20])
data.add_row(["Magical", 1])
return data
For an expanation of this code, read on to the getting started section.