@robocop45
Only python

Почему счетчик уведомлений виден только на определенной вкладке?

Сделал уведомления и добавил счетчик, который добавлен в base.html, но отображается только, на вкладке уведомления 63ed0faab6a5e859816077.jpeg

т.е эта циферка 1 отображается, только когда тыкаешь на вкладку "Уведомления"

base.html
<span class="badge">{{ notifications.count }}</span>
<li><a href="{% url 'show-notifications' %}">Уведомления</a></li>


views.py

<code lang="python">
def ShowNotifications(request):
    user = request.user


    notifications = Notification.objects.filter(user=user).order_by('-date')
    Notification.objects.filter(user=user, is_seen=False).update(is_seen=True)

    dict = {
        'notifications': notifications
    }
    return render(request, 'notice/notifications.html', dict)
</code>


notifications.html
{% extends 'blog/base.html' %}


{% block content %}
<td valign="top" class="content">

    {%if notifications.count >= 1 %}
    <h4><a href="{% url 'delete-all_notifications' %}" class="delete">Очистить все</a></h4>
    {%endif%}
    {% for notification in notifications %}
    {% if notification.notification_type == 2 %}


    <div class="notification">

        <article class="media">
            <figure class="media-left">

                {% if notification.sender.photo %}
                <img class="d-flex g-width-50 g-height-50 rounded-circle g-mt-3 g-mr-15"
                     src="{{ notification.sender.photo.url }}" alt="Image Description">
                {% else %}
                <img src="https://bulma.io/images/placeholders/96x96.png" alt="Placeholder image">
                {% endif %}

            </figure>

            <div class="media-content">
                <div class="content">
                    <strong><a href="{% url 'question' notification.post.id%}">{{notification.post}}</a></strong><br>
                    <strong>{{ notification.sender }}</strong>

                    <hr>
                    Оставил комментарий:
                    <strong>{{ notification.text_preview }}</strong><br>
                    <strong><small>{{ notification.date }}</small></strong>
                </div>
            </div>

            <div class="media-right">
                <figure class="image is-128x128">
                    <img src="{{ notification.post.picture.url }}">
                </figure>
            </div>
        </article>

    </div>
    {% endif %}
    {% empty%}
    <h2>уведомлений нету</h2>

    {% endfor %}

    <!-- FOR LIKES --->
    
</td>
{%endblock%}
  • Вопрос задан
  • 73 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы