django-notifications-hq: cannot show notifications

2k views Asked by At

while the 'unread_list' API works, I cannot get the tag {% live_notify_list list_class="dropdown-menu" %} to work.

The tag definition is:

def live_notify_list(list_class='live_notify_list'):
  html = "<ul class='{list_class}'></ul>".format(list_class=list_class)
  return format_html(html)

correct me if I am wrong, but this doesn't do anything but returning an unsorted list. I would like to display all the notifications. According to the documentation (documentation) all I need to do is to use {% live_notify_list %} however, this doesn't display anything.

The library I am using at github.

1

There are 1 answers

0
django11 On BEST ANSWER

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).