python - 如何显示来自 `django-notification` 的通知?

标签 python django django-notification

我一直在阅读 django-notification 的文档,它们似乎涵盖了如何创建通知,但没有涵盖如何向用户显示通知。有没有很好的引用资料,我的 Google-fu 刚刚让我失望了?如果没有,有人可以在这里给我一些指示吗?谢谢。

最佳答案

答案是您必须将其构建到您自己的模板中。这可以像以下代码片段一样简单:

<table>
    <caption>{% trans "Notices" %}</caption> 
    <thead>
        <tr>
            <th>{% trans "Type" %}</th>
            <th>{% trans "Message" %}</th>
            <th>{% trans "Date of the Notice" %}</th>
        </tr>
    </thead>
    <tbody>
        {% for notice in notices %}
            {% if notice.is_unseen %}
                <tr class="unseen_notice">
            {% else %}
                <tr class="notice">
            {% endif %}
                <td class="notice_type">[{% trans notice.notice_type.display %}]</td>
                <td class="notice_message">{{ notice.message|safe }}</td>
                <td class="notice_time">{{ notice.added|timesince }} {% trans "ago" %}</td>
            </tr>
        {% endfor %}
    </tbody>
</table>

作为@googletorp answered , Pinax是找出作者如何使用 django-notification 的转到位置。特别是,有一个通知管理页面可以作为一个方便的指南。

关于python - 如何显示来自 `django-notification` 的通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1609775/

相关文章:

python - PyAudio 在 ubuntu 上不工作并破坏声音

python - 类型错误 : not enough arguments for format string - Python Formatting Issue

python - 事件流中的匿名参与者

python - 如果表单在 django for 循环中,如何检索 html 表单的输入值

django - 在Django中的save()中执行delete()

python - 当有人评论他们的帖子时如何使用 django-notification 通知用户

django-通知-hq : cannot show notifications

可以访问包括单词定义在内的英语词典的 Python 模块

Python - 从文件中删除一行(使用条目的待办事项列表程序,与其他帖子不同)

python - 多对多字段 django 添加双向关系