I ham trying to hide the notification count when it's 0 in django-notifications-hq I have tried the below method but it is not updating regularly and displaying the number correctly.
{% live_notify_badge as nc %}
{% if nc > 0|add:0 %}
<span class="badge-notifications badge badge-pill badge-danger" style="float:right;margin-bottom:-3px;margin-top: -2px !important; margin-left: 10px !important; font-size: 0.6rem;">
{% live_notify_badge %}</span>
{% endif %}
nc
is not the number of notifications. It generates some HTML that will make Javascript calls to fetch the number of notifications.You can obtain the number of unread notifications in the template with:
So we can check if an unread notification exists, and use this to render the
{% live_notify_badge %}
:Note however that this will be rendered at server side, so that means that when the user fetches the page, and there are no notifications, it will not display the badge. If however later there are notifictions these will not be rendered.