[Django]-Django-notifications-hq: cannot show notifications

4👍

DevKing, hopefully you have solved the issue. To give more context, the {% live_notify_list %} is used for getting real-time updates of notifications that can be used in a dropdown on a navbar. A user can click and get a dropdown of the most recent notifications (the default is 5). If you want a list of all notifications, you can provide a link to {% url ‘notifications:unread’ %}.


You will need to include this

{% load notifications_tags %}
    <script src="{% static 'notifications/notify.js' %}" type="text/javascript"></script>
    {% register_notify_callbacks callbacks='fill_notification_list,fill_notification_badge' %}

And then you can place this within your navbar

            <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                    Notifications {% live_notify_badge %}
                    <span class="glyphicon glyphicon-user pull-right">

                    </span>
                </a>
                <ul class="dropdown-menu" id="notice-link">
                  <a href="{% url 'notifications:unread' %}">
                    {% live_notify_list %}
                  </a>
                </ul>
            </li>

The {% live_notify_badge %} will show you the number of unread notifications while the {% live_notify_list %} will provide the list of recent notifications. The js added above will pull new notifications every 15 seconds (which you can make shorter/longer).

Leave a comment