Skip to main content

install

pip install django-simple-notification

Usage

1. create notification events

from notifications.handlers import send_message

send_message('Mahmoud Liked your post', user, 'post_like')

Explain

# function interface
send_message(message:str, user:User, type:str)

# logic behind it
message: the text message to be sent to the user
user: an instance of User model (the one who will recieve the notification)
type: is a notification tag or type (you should create difrrent types in your system for different events)

2.fetch notifications using REST APIs

notifications/all/:GET : get all the notifications



notifications/mark/:PUT : mark all notifications as read

img_1.png


notifications/unread/:GET: get all unread notifications

img_2.png

3.how the client side recieve the message from the server via websocket

img.png

configration

Note: make sure that django channels is up and running and also you django serves under ASGI check this url to configure django channels in your project

in settings.py

INSTALLED_APPS = [
    ...
    'channels', # django channels needs to be installed
    'notifications', # our package
    ...   
]
SIMPLE_NOTIFICATION_SETTINGS = {
    'receive_handler_path': 'custom_module.custom_py_file.custom_receive_handler',
}

in urls.py

path('api/v1/notifications/', include('notifications.urls')),

in asgi.py

from notifications import routing

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'demo_project.settings')

application = ProtocolTypeRouter({
    'http': get_asgi_application(),
    'websocket': AuthMiddlewareStack(
        URLRouter(
            routing.websocket_urlpatterns
        )
    ),
})

run make migrate:

python manage.py migrate

Metadata

Release files for django-simple-notification 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-simple-notification 1.0.5
File Size Uploaded Provenance
django-simple-notification-1.0.5.tar.gz 6.7 kB Without provenance Details

Release files / django-simple-notification-1.0.5.tar.gz

Download URL django-simple-notification-1.0.5.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
54a57081d46f9726d78d248799d001a2a3cac7874b855a671b41c0706b253bed
BLAKE2b-256 checksum
How to use checksums
45f3559603e264bca2338c8a0a375a2fa8c9da2b81cbeb88d4aa3e9c23509cbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Security for django-simple-notification 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page