Package: django-notify-x
Django NotifyX is a reusable app which adds notification system features to your Django app.It was inspired fromdjango-notifications, major differences include:Multipe user notification at once.A different approach for notification updates.Less hassles when trying to format notifications differently according to their types.AJAX support for everything.And many more.This is just a quick guide to get things to work ASAP. To dive into the details..Read the docsHow to installDownloading the packageProbably the best way to install is by usingPIP:$ pip install django-notify-xIf you want to stay on the bleeding edge of the app:$ git clone https://github.com/v1k45/django-notify-x.git
$ cd django-notify-x
$ python setup.py installInstalling it on your projectAfter the you’ve installeddjango-notify-xin your python enviroment. You have to make an entry of the same in your projectsettings.pyfile:INSTALLED_APPS = (
    ...
    'your.other.apps',
    ...
    'notify',
)Then an entry on theurls.pyfile:urlpatterns = (
    url(r'^notifications/', include('notify.urls', 'notifications')),
)Then run migrations:$ python manage.py migrate notifyThencollectstaticto make sure you’ve copied the JS file for AJAX functionality:$ python manage.py collectstaticYou’ve successfully installeddjango-notify-x!Sending notificationsSending notifications to a single user:fromnotify.signalsimportnotify# your example viewdeffollow_user(request,user):user=User.objects.get(username=user)...dofollow...notify.send(request.user,recipient=user,actor=request.userverb='followed you.',nf_type='followed_by_one_user')returnYourResponseEasy as pie, isn’t it?Sending notifications to multiple users:fromnotify.signalsimportnotify# your example viewdefupload_video(request):...uploadvideo......video=VideoUploader.getupload()followers=list(request.user.followers())notify.send(request.user,recipient_list=followers,actor=request.userverb='uploaded.',target=video,nf_type='video_upload_from_following')returnYourResponseJust change therecipienttorecipient_listand send notifications to as many users you want!Warningrecipient_listexpects supplied object to be a list() instance, make sure you convert yourQuerySetto list() before assigning vaule.Notification concatenation supportNotification Concatenation is what you see when you read notifications likeBob and 64 others liked your status. A developmental support is available for it, but it only supports Python3 for now.If you use Python3, you can add this feature to your application.
Please read instructions onnf_concat_supportbranch.Notification Template tagsThis app comes with two notification tags, one renders notifications for you and the other includes javascript variables and functions relating thenotifyX.jsfile.render_notificationsAs its name reflects, it will render notifications for you.render_notificationswill take at least one parameter and maximum two parameters.You can use them to render notifications using aNotificationQuerySet object, like this:{% load notification_tags %}
{% render_notifications using request.user.notifications.active %}By default, the above tag will render notifications on the notifications page and not on the notification box. So it will use a template corresponing to it’snf_typewith a.htmsuffix nothing more.To render notificatons on a notifications box:{% load notification_tags %}
{% render_notifications using request.user.notifications.active for box %}This tag will look for template name with_box.htmlsuffixed when rendering notification contents.Therequest.user.notifications.activeis just used to show an example of notification queryset, you can use any other way to supply a QuerySet of your choice.include_notify_js_variablesThis tag usesnotifications/includes/js_variables.htmlto include a template populated with JS variables and functions. You can override the values of any JS variables by creating your own version ofjs_variables.htmltemplate.To include JS variables for AJAX notification support, do this:{% load notification_tags %}
{% include_notify_js_variables %}This template inclusion includes three javascript files from the template includes directory, they are:mark_success.js
mark_all_success.js
delete_success.js
update_success.jsAll of them are nothing but javascript function declarations which are supposed to run when a JQuery AJAX request is successfully completed.user_notificationsTheuser_notificationstag is a shortcut to therender_notificationstag. It directly renders the notifications of the logged-in user on the specified target.You can use this tag like this:{% load notification_tags %}
{% user_notifications %}This tag renders active notifications of the user by using something likerequest.user.notifications.active().Just likerender_notificationsit also takes rendering target as an optional argument. You can specify rendering target like this:{% load notification_tags %}
{% user_notifications for box %}By default, it’ll use ‘page’ as the rendering target and use full page notification rending template corresponding to thenf_typeof the template.And other things…It will be best toRead the Docsinstead of expecting every thing from a quick guide :)TODO ListAdd notification concatenation support.Notification concatenation is what facebook does when you read a notification likeBob and 18 others commented on your blogpost.This will require non-anonymous activity stream field.I’ve to either remove the anonymous notification support or find another way to implement this feature.work in progress!ConvertFunction based viewstoClass Based views.