Skip to main content

DSN or django-signal-notifier is a Django package to send message or notification based on the Django's signals triggering

Project description

Documentation Project on PyPI

DSN or django-signal-notifier is a Django package to send message or notification based on the Django’s signals triggering. You can assign some backends to each signal(e.g., An In-Site notification app).

The major difference between django-signal-notifier and other Django’s notification packages is that DSN isn’t just a simple message delivering system. It can act as a middleware between Django and every messenger client (Various clients like email, telegram, SMS and twitter).

It’s working with event methodology, and it’s based on Django signal. If a signal triggers, A messenger is called to send a message for specified users. To understand how it works, We explain some main concepts at first.

Documentation, installation and getting started instructions are at documentation

Concepts (Summary)

DSN’s architecture :

DSN Architecture

In a nutshell, we can say DSN is developed to send message :

  • When and Where ? : When a Trigger Triggered (The associated signal’s send function is called, and the trigger’s specs match).

  • What to send?: The message that is created to the message_template and other parameters like signal_kwargs.

  • Whom to send? : Send the message to the registered receivers in the subscription or the dynamic user that can be specified in the messenger.

Setup

Requirements

  • Python 2.7, 3.4, 3.5, 3.6, 3.7

  • Django 1.7, 1.8, 1.9, 1.10, 1.11, 2.0, 2.1, 2.2, 3.0

Installation

1. Install django-signal-notifier by pip:

$ pip install django-signal-notifier

or use the source

$ git clone https://github.com/hadi2f244/django-signal-notifier
$ cd django-signal-notifier
$ python setup.py sdist
$ pip install dist/django-signal-notifier*
  1. Add “django_signal_notifier” at the end of INSTALLED_APPS setting like this

INSTALLED_APPS = [
    'django.contrib.auth',
    'django.contrib.contenttypes',
    ...
    'django_signal_notifier',
]
  1. Migrate

  2. django-signal-notifier configure by admin panel by default(Can be configured by code, tough)

  3. Use python manage.py migrate for schema migration.

Usage

  1. Run the development server and visit http://127.0.0.1:8000/admin/ To create a trigger(signal), backends(messenger and message_template), and subscription (you’ll need the Admin app enabled).

  2. You can test it like this:

    5.1. Create a trigger (verb=pre_save and action_object=TestModel1)

    5.2. Create a backend (messenger=SimplePrintMessengerTemplateBased and message_template=SimplePrintMessageTemplate)

    5.3. Create a subscription that connects the trigger and the backend. Add admin to the receiver(user) list.

    5.4. Run this command in manage.py shell:

    from django_signal_notifier.models import *
    TestModel1_another_instance = TestModel1.objects.create(name="new_test_model2", extra_field="extra")

    Now you should see a message when you create TestModel1. By Creating new TestModel1, Django calls the pre_save signal’s send method. Then this signal call associated trigger handler. In the Trigger handler, the associated backend is called. The message_template with some details are sent to the backend. In our case, a simple message is printed. You can provide your messengers and message_templates.

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-signal-notifier-0.2.1.tar.gz (46.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_signal_notifier-0.2.1-py3-none-any.whl (42.5 kB view details)

Uploaded Python 3

File details

Details for the file django-signal-notifier-0.2.1.tar.gz.

File metadata

  • Download URL: django-signal-notifier-0.2.1.tar.gz
  • Upload date:
  • Size: 46.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for django-signal-notifier-0.2.1.tar.gz
Algorithm Hash digest
SHA256 02b591816c3aaeb417fdcd6f73c10ef427006823d76815c8ae5ee615ccb59756
MD5 438b890a6259989b164b244da2b6fa8f
BLAKE2b-256 2373c86b89f87a47bd1ca90ab58dbc1a4972dc976ccd7bab249bcf1db1cc7f7f

See more details on using hashes here.

File details

Details for the file django_signal_notifier-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: django_signal_notifier-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 42.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for django_signal_notifier-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2a492ebac2fb61f7a0bc4ea398fa9a71cdb500c3ae4d4f2f0e5a7102d458ce05
MD5 e55cf7af292693e5b54cc6f9955a2b7e
BLAKE2b-256 611e24719f9ee5add63b773d9354876c16983af7d0d275d4e20f357b9d812133

See more details on using hashes here.

Supported by

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