pythondjangonotificationsdjango-notification

Django Unread Messages System


I am currently in the process of implementing a Django based peer to peer quizzing system wherein a user can challenge another user for a quiz.(Much like quizup). I have implemented nearly all the major components of it and the last remaining one is in-website user notification - wherein the user is able to see the number of new unresponded challenges to him.

Django-notification, it seems , uses email based notification,but I want to notify the user within the website itself - just like StackOverflow has for unread notifications/messages, the user will be able to see the number of active challenges under a challenges tab. It need not be real-time like StackOverflow though.

Have extensively Googled,but failed to find a solution.

Any help would be appreciated.


Solution

  • If you want a delayed sort of update, have a JavaScript setinterval call that repeats an Ajax call to a view to check notifications.

    For instance, in your base template, have something like this (using jQuery)

    function checkNotifications() {
        $.get("url", function(data) {
                // do something with the data
            }
        });
    }
    setInterval(checkNotifications, 30000);
    

    to check notifications every 30 seconds.

    WebSockets can be used for a live update mechanism. I haven't used websockets with Django, but this project looks active and was top on my Google search.