Han*_*Gay 8 python django django-notification
我一直在阅读文档django-notification,它们似乎涵盖了创建通知,但不是如何将它们显示给用户.那里有一个很好的参考,我的谷歌刚刚失败了吗?如果没有,有人可以给我一些指示吗?谢谢.
答案是您必须将其构建到您自己的模板中。这可以像下面的代码片段一样简单:
<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>
Run Code Online (Sandbox Code Playgroud)
正如 @googletorp所回答的,Pinax是了解作者如何使用的最佳地点django-notification。特别是,有一个通知管理页面可以作为方便的指南。