如何显示`django-notification`的通知? [英] How do I display notifications from `django-notification`?
问题描述
我一直在阅读 django的文档-notification
,它们似乎涵盖了创建通知,但不是如何将它们显示给用户。有没有很好的参考,我的Google-fu刚刚失败了我?如果没有,有人可以给我一些指针吗?谢谢。
I've been reading the docs for django-notification
, and they seem to cover creating notifications just fine, but not how to display them to users. Is there a good reference for this out there, and my Google-fu has just failed me? If not, can someone give me some pointers here? Thanks.
推荐答案
答案是您必须将其构建到您自己的模板中。这可以像以下代码片段一样简单:
The answer is you have to build it into your own templates. This can be as simple as the following snippet:
<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>
As @googletorp 回覆, Pinax 是找出作者如何使用 django-notification
的goto地方。特别是,有一个通知管理页面可以作为一个方便的指南。
As @googletorp answered, Pinax is the goto place for figuring out how the authors are using django-notification
. In particular, there is a notification administration page that can serve as a handy guide.
这篇关于如何显示`django-notification`的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!