django-reporting

An application that can be integrated with the Django Admin and allows you to create dynamic reports fo...
Download

django-reporting Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL
  • Price:
  • FREE
  • Publisher Name:
  • Rodrigo Herrera, Vitaliy Kucheryaviy and Marc Garcia
  • Publisher web site:
  • https://github.com/tryolabs/

django-reporting Tags


django-reporting Description

django-reporting is a Django app that can be integrated with the Django Admin and allows you to create dynamic reports for your models. Consolidating and aggregating data, filtering and sorting it.InstallationClone repository and do: python setup.py installOr just do pip install django-reportingto get the latest version from pypi.How to use itAdd to INSTALLED_APPS in an existing django project:settings.pyINSTALLED_APPS = ( 'reporting', 'django.contrib.admin', # admin has to go before reporting in order to have links to the reports # on the admin site)urls.pyfrom django.conf.urls.defaults import *from django.contrib import adminimport reporting # import the moduleadmin.autodiscover()reporting.autodiscover() # autodiscover reports in applicationsurlpatterns = patterns('', (r'^reporting/', include('reporting.urls')),)Configure reportLet's say you have the following schema:models.pyclass Department(models.Model): class Occupation(models.Model): class Person(models.Model): name = models.CharField(max_length=255) occupation = models.ForeignKey(Occupation) department = models.ForeignKey(Department) country = models.ForeignKey(Country) birth_date = models.DateField() salary = models.DecimalField(max_digits=16, decimal_places=2) expenses = models.DecimalField(max_digits=16, decimal_places=2)In your application create a reports.pyreports.py:import reportingfrom django.db.models import Sum, Avg, Countfrom models import Personclass PersonReport(reporting.Report): model = Person verbose_name = 'Person Report' annotate = ( # Annotation fields (tupples of field, func, title) ('id', Count, 'Total'), # example of custom title for column ('salary', Sum), # no title - column will be "Salary Sum" ('expenses', Sum), ) aggregate = ( # columns that will be aggregated (syntax the same as for annotate) ('id', Count, 'Total'), ('salary', Sum, 'Salary'), ('expenses', Sum, 'Expenses'), ) group_by = list_filter = # if detail_list_display is defined user will be able to see how rows was grouped detail_list_display = date_hierarchy = 'birth_date' # the same as django-adminreporting.register('people', PersonReport) # Do not forget to 'register' your class in reportsFor more details see a 'samples' projects inside the repository.Product's homepage


django-reporting Related Software