我一直在阅读 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/