Skip to main content

The Django package to send all type of notifications like magic

Project description

======================================= Django Magic Notifier

A notifications library for Djangonauts

.. image:: https://api.travis-ci.com/jefcolbi/django-magic-notifier.svg?branch=main :target: https://travis-ci.com/github/jefcolbi/django-magic-notifier :alt: Build status on Travis-CI

.. image:: https://coveralls.io/repos/github/jefcolbi/django-magic-notifier/badge.svg?branch=main :target: https://coveralls.io/github/jefcolbi/django-magic-notifier?branch=main :alt: Coverage status on coverage.io

.. image:: https://img.shields.io/pypi/v/django-magic-notifier.svg :target: https://pypi.org/project/django-magic-notifier/ :alt: Current version on PyPi

.. image:: http://readthedocs.org/projects/django-magic-notifier/badge/?version=stable :target: https://django-magic-notifier.readthedocs.io/en/stable/ :alt: Documentation

.. image:: https://img.shields.io/pypi/pyversions/django-magic-notifier :alt: PyPI - Python Version

.. image:: https://img.shields.io/pypi/djversions/django-magic-notifier :alt: PyPI - Django Version


Why Django Magic Notifier?


Sending notifications in Django has always been a complex subject. Django Magic Notifier solves this by providing only one function notify(). The library [will] support sending notifications via email, sms and push notifications.


Installation


$pip install --upgrade django-magic-notifier


Features


- Send emails
- Email templates

Usage


  1. Configure Settings ^^^^^^^^^^^^^^^^^^^^^

If you have already configured SMTP SETTINGS via django settings then can ignore this step. Else add a NOTIFIER dict in your settings like this

.. code-block:: python

NOTIFIER = {
    "SMTP": {
        "default": {
            "HOST": "localhost",
            "PORT": 587,
            "USE_TLS": True,
            "USE_SSL": False,
            "USER": "root@localhost",
            "FROM": "Root <root@localhost>",
            "PASSWORD": "********",
            "CLIENT": "magic_notifier.email_clients.django_email.DjangoEmailClient",
        }
    }
    "THREADED": False,
}
  1. Create email templates ^^^^^^^^^^^^^^^^^^^^^^^^^ Create a folder named notifier in one of app's templates dir. In this folder create another folder named base then created your base templates in this folder. Example

core/templates/notifier/base/email.html

.. code-block:: html

{% extends "base_notifier/email.html" %}

core/templates/notifier/base/email.txt

.. code-block:: html

{% extends "base_notifier/email.txt" %}

*core/templates/notifier/hello/email.html * .. code-block:: html

{% extends "notifier/base/email.html" %}
{% block content %}
<tr>
    <td><p>Hello {{ user.email }}
    </td>
</tr>
{% endblock %}

core/templates/notifier/hello/email.txt

.. code-block:: html

{% extends "notifier/hello/email.txt" %}
{% block content %}
>Hello {{ user.email }}
{% endblock %}

As you can see, the user to whom the notification goes is automatically added in the template's context. To avoid any clash to don't use the key 'user' in the notifiy function presented below.

Note that it is DMN (Django Magic Notifier) that has the base_notifier template.

To send a notification via email do

.. code-block:: python

from magic_notifier.notifier import notify

# send an email from direct string
user = User(email="testuser@localhost", username="testuser")
subject = "Test magic notifier"
notify(["email"], subject, [user], final_message="Nice if you get this")

# send an email from a template
user = User(email="testuser@localhost", username="testuser")
subject = "Test magic notifier"
notify(["email"], subject, [user], template='hello')

Docs and support


Coming


Roadmap


- [] Send sms
- [] Send push notifications
- [] Generate full documentation
- [] Translate documentation

Contributing


Contribution are welcome and required.


License


As per the license, feel free to use the library as you want.

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-magic-notifier-0.0.5.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

django_magic_notifier-0.0.5-py2.py3-none-any.whl (27.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-magic-notifier-0.0.5.tar.gz.

File metadata

  • Download URL: django-magic-notifier-0.0.5.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.13

File hashes

Hashes for django-magic-notifier-0.0.5.tar.gz
Algorithm Hash digest
SHA256 894603b94f8d30f8b12dcc1a90c584325fc583832173a08504e8166a589ba9a1
MD5 b41f3fedb0d394db3535440464053178
BLAKE2b-256 f3d52ac5b867dff4c9df1d482e7b5a7a4c62b5ea3dd3fccae236045fc3e14c07

See more details on using hashes here.

File details

Details for the file django_magic_notifier-0.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: django_magic_notifier-0.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 27.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.6.13

File hashes

Hashes for django_magic_notifier-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bf295bb18ebfcba91b76f83bfad2f3382aa0262479688d8e6ad92000f92ced2c
MD5 ac1c3f0cde366e29fc8954ef2aea4fd2
BLAKE2b-256 4df7feae3277c3595d013b845064e75f2c6a46f7ae5adfac320ea218d3cf4349

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