Package: django-easy-notify
django-easy-notifydjango-easy-notify is Django App to create/send notification by calling just hit of single function.Quick StartAdd 'notifications' to your INSTALLED_APPS setting like this::INSTALLED_APPS = [
    ...
    'daphne',
    'channels',
    'notifications',
]Runpython manage.py migrateto create the django-mails models.Add Templates path to your TEMPLATES in setting.pyimport method to send emailfrom notifications.utils import send_notificationUse methodfrom notifications.utils import get_notificationsto receive notifications based on status/all notifications.DescriptionTo Send or Create Notificationsend_notification(
    title : str,
    receivers : list[User],
    sender : User,
    notification_type : str,
    message : str = None,
    category : Category = None,
    real_time_notification : bool = False
)This function will create in-app notification with required details.Parameters:title : stringreceivers : List of User model instancesender : User model instancenotification_type :
a. success
b. error
c. warning
d. infomessage : stringcategory : Category Model instancenotification_status :
a. read
b. unread
c. deletedreal_time_notification : bool (Set True if you want to implement Real-Time Notifications)To fetch notificationsget_notifications(user, notification_status = None):Parameters:user : Instance of User Model (Receiver)notification_status :
a. read
b. unread
c. deleted
Note : Set None to receive all notifications.Mark as Readmark_as_read(user)Parameters:user : Instance of User Model (Receiver)Mark as Unreadmark_as_unread(user)Parameters:user : Instance of User Model (Receiver)Django Channels SettingASGI_APPLICATION = "<your_project_name>".asgi.application"
CHANNEL_LAYERS = {
    "default": {
        "BACKEND": "channels_redis.core.RedisChannelLayer",
        "CONFIG": {
            "hosts": [("localhost", 6379)],
        },
    },
}Update ASGI fileimport os

from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application

import notifications.routing

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "<your_project_name>.settings")

application = ProtocolTypeRouter(
    {
        "http": get_asgi_application(),
        "websocket": AuthMiddlewareStack(
            URLRouter(notifications.routing.websocket_urlpatterns)
        ),
    }
)Script to work with websockets on Frontend side.<script>
    var loc = window.location
        var wsStart = "ws://"
        if (loc.protocol == "https:"){
            wsStart = "wss://"
        }
        var webSocketEndpoint =  wsStart + loc.host + '/ws/notifications/' + "{{user.id}}/" // ws : wss   // Websocket URL, Same on as mentioned in the routing.py


        var socket = new WebSocket(webSocketEndpoint) // Creating a new Web Socket Connection

        // Socket On receive message Functionality
        socket.onmessage = function(e){
            console.log('message', e)
            console.log(JSON.parse(e.data))
        }

        // Socket Connet Functionality
        socket.onopen = function(e){
            console.log('open', e)
            socket.send(JSON.stringify({
                "command":"fetch_all_notifications" // send command to fetch all unread notifications
            }))
        }

        // Socket Error Functionality
        socket.onerror = function(e){
            console.log('error', e)
        }

        // Socket close Functionality
        socket.onclose = function(e){
            console.log('closed', e)
        }
</script>Setup guidelinebuild: Create the build and runtime imagesdocker-compose buildup: Start up the projectdocker-compose upTo see services and their portsdocker psshell: Shell into the running Django containerdocker exec -it CONTAINER ID /bin/bashmigrate: Changes you have made to your modelspython manage.py makemigrations
   python manage.py migrate
   python manage.py createsuperuser