Skip to main content

Simple reporting for Django admin.

Project description


Simple report generation. Can be used to generate any kind of CSV or HTML reports. Instead of binding the complicated joins in class it expects a queryset to be provided along with headers (which are basically the text values for the first row of the HTML table or CSV file). Further, it requires the redefinition of the process_data which produce a Python list of lists. Each element of the list shall contain exactly the same number of items as the headers. There are some filtering options built in (date_upper, date_lower, per_page, page). Refer to the code documentation further.

There are some obligatory attributes that should be set in the child class:
  • verbose_name (example: verbose_name = ‘Article word count’)

  • fields (example: fields = [u’Article ID’, u’Title’, u’Slug’, u’URL’]

  • queryset (example: queryset = Article._default_manager.all())

If you want to have the date filtering set, you should provide the following attribute as well:
  • date_field (example: date_field = ‘date_published’)


GPL 2.0/LGPL 2.1


  1. Latest stable version on PyPI:

    $ pip install sirep

Or, eventually, the latest development version

$ pip install -e hg+

  1. Add ‘sirep’ to your INSTALLED_APPS:

    >>> INSTALLED_APPS = (
    >>> # ...
    >>> 'sirep',
    >>> # ...
    >>> )
  2. Run the following django management command:

    $ ./ collectstatic

  3. Add the following lines to the global file:

    >>> import sirep
    >>> sirep.autodiscover() # autodiscover sirep in applications
    >>> urlpatterns = patterns('',
    >>>    # ... some patterns here
    >>>    # Sirep URLs
    >>>    (r'^sirep/', include('sirep.urls')),
    >>>    # ... some other patterns here
    >>> )

5. Create a report in the app directory for which you make the report and name the file “” (follow the sirep.reports example). In order to see the demo, set the SIREP_SHOW_ADMIN_TEST_MODEL_DEMO to True in your local_settings and visit the “http://localhost:8000/sirep/” URL.

Usage examples

It might be just as easy to check the source code (example directory), since it works out of the box (to get an idea of what it is):

Sample model module (file test_package/

>>> class TestModel(models.Model):
>>>     """
>>>     Test model for making a report.
>>>     """
>>>     title = models.CharField(_("Title"), max_length=50, blank=False, null=False)
>>>     counter = models.PositiveIntegerField(_("Counter"), blank=True, null=True)
>>>     user = models.ForeignKey(User, null=True, blank=True)
>>>     date_published = models.DateTimeField(null=True, blank=True)
>>>     class Meta:
>>>         verbose_name = _("Sirep test model")
>>>         verbose_name_plural = _("Sirep test models")
>>>     def __unicode__(self):
>>>         return self.title

Sample report (file test_package/ module:

>>> import sirep
>>> from test_package.models import TestModel
>>> # Define the report class
>>> class TestReport(sirep.Report):
>>>     verbose_name = 'Test report'
>>>     fields = [u'ID', u'Title', u'Counter', u'Username', u'E-mail']
>>>     items = []
>>>     limit = 200
>>>     date_field = 'date_published'
>>>     queryset = TestModel._default_manager.filter().select_related('user')
>>>     def process_data(self):
>>>         queryset = self.get_queryset()
>>>         self.items = []
>>>         for a in queryset:
>>>             self.items.append([
>>>       ,
>>>                 a.title,
>>>                 a.counter,
>>>                 a.user.username if a.user else '',
>>>        if a.user else ''
>>>                 ])
>>> # Register the report
>>> sirep.register('test-report', TestReport)

That’s all. You may now navigate to your report Note that test-report is the slug using which we have registered the report (sirep.register).


Artur Barseghyan <>

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sirep-0.3.tar.gz (8.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page