Skip to main content

Send alerts, notifications, and messages based on events in your django application

Project description

[![Build Status](https://travis-ci.org/jiaaro/django-alert.png?branch=master)](https://travis-ci.org/jiaaro/django-alert)

## Installation ##

1. Install lib with pip:

`pip install django-alert`

**- OR -**

Put the "alert" directory somewhere in your python path

2. Add "alert" to your installed apps (in the settings.py file)
3. Also add "django.contrib.sites" in installed apps in case it's not there.
4. Run ./manage.py migrate


## Making Alerts ##

Create an "alerts.py" file and import it at the bottom of your
models.py file. This is where you will define your alert class. Every
alert is subclassed from "alert.utils.BaseAlert"

Here is an example alert that is sent to users when they first sign up:

from django.contrib.auth.models import User
from django.db.models.signals import post_save
from alert.utils import BaseAlert

class WelcomeAlert(BaseAlert):
title = 'Welcome new users'
description = 'When a new user signs up, send them a welcome email'

signal = post_save
sender = User

default = False

def before(self, created, **kwargs):
return created

def get_applicable_users(self, instance, **kwargs):
return [instance]


## Writing Alert Backends ##

Alert includes an Email Backend by default. But you can write a backend
for *any* messaging medium!

Alert Backends just need to subclass BaseAlertBackend and implement a
`send()` method that accepts an alert instance

You can copy and paste the following code to get started:

from alert.utils import BaseAlertBackend

class MyAlertBackend(BaseAlertBackend):
def send()


## Signals ##

When an alert is sent, a signal is fired (found in alert.signals). The
"sender" keyword argument is the Alert you defined (WelcomeAlert in
this case).

example:

from alert.signals import alert_sent

def do_something_after_welcome_alert_is_sent(sender, alert, **kwargs):
pass

alert_sent.connect(do_something_after_welcome_alert_is_sent,
sender=WelcomeAlert)

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

django-alert-0.8.1.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

django_alert-0.8.1-py2.py3-none-any.whl (23.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-alert-0.8.1.tar.gz.

File metadata

File hashes

Hashes for django-alert-0.8.1.tar.gz
Algorithm Hash digest
SHA256 30c065f0d66a78698871c723f6348a329ad52593c8cc096b2afcef04114e8f41
MD5 46dd567d61c15cf2163ab82b4099f1a4
BLAKE2b-256 e8722b26dd04220d5ac63b09557e28fe0b89613f35dcc0f9515c6e5e841d9b97

See more details on using hashes here.

File details

Details for the file django_alert-0.8.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_alert-0.8.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a1f2f9afc0324c44dfa5c171752597f13f07efae68cb7c120be044183bc0914e
MD5 3dc1eeadb2e687abfba661f9488b0864
BLAKE2b-256 0aee4c666679caf2bf2b9f8425e373fe7e4d12ab1d29893fc676bea16b64001d

See more details on using hashes here.

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