Skip to main content

django library to render and send report mail.

Project description

Django library to send ‘report’ mail.

Almost django management commands used as night batch processing, and then, administrators will want to know the result of it as mail.

Why django-reportmail

Of Cause, you can emit logs and aggregate them by using some another applications like Sentry. But in some cases, you can’t deploy them and you should send the report as mail.

Usage

import csv
from django.core.management.base import BaseCommand

from reportmail.command import apply_reporter

class Command(BaseCommand):
    @apply_reporter("Title")
    def handle(reporter, filepath, *args, **options):
        for i, l in enumerate(csv.DictReader(open(filepath))):
            reporter.append('Line {}: processed {l}'.format(i+1, l))

Then, when the command finish, you’ll get a admin mail like this:

Subject:
    Title
Body:
    Report of someapp.management.commands.some_of_your_command
    args: path/to/somecsv.csv
    options:

    result:
    Line1: processed {'somefield': 'somevalue0'}
    Line2: processed {'somefield': 'somevalue1'}
    Line3: processed {'somefield': 'somevalue2'}
    Line4: processed {'somefield': 'somevalue3'}
    ...

Required settings

First, Add a line ‘reportmail’ to INSTALLEDAPPS to register this library for your project:

INSTALLED_APPS = (
    ...
    'reportmail',
)

And also you need to set ‘ADMINS’ settings. Because the above ‘apply_reporter’ will send the report mail to ADMINS on settings.

ADMINS = (
    ('Hiroki KIYOHARA', 'hirokiky@gmail.com'),
)

Versions

Python:

  • 2.7
  • 3.3

Django:

  • 1.6

Resources

Project details


Release history Release notifications

History Node

1.3

History Node

1.2.4

History Node

1.2.3

History Node

1.2.2

History Node

1.2.1

History Node

1.2

History Node

1.1

History Node

1.0

History Node

1.0b2

This version
History Node

1.0b1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-reportmail-1.0b1.tar.gz (3.5 kB) Copy SHA256 hash SHA256 Source None May 24, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page