代码之家  ›  专栏  ›  技术社区  ›  Hank Gay

如何显示来自“django notification”的通知?

  •  8
  • Hank Gay  · 技术社区  · 16 年前

    我一直在看医生 django-notification 它们似乎包括创建通知,但不包括如何向用户显示通知。有没有一个很好的参考,我的google fu刚刚失败了?如果没有,有人能给我一些提示吗?谢谢。

    2 回复  |  直到 12 年前
        1
  •  4
  •   Community Mohan Dere    9 年前

    答案是你必须把它构建成你自己的模板。这可以像下面的代码片段一样简单:

    <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>
    

    作为@ GoGoTeloPrP answered , Pinax 是了解作者如何使用 django-notification . 特别是,有一个通知管理页面可以作为一个方便的指南。

        2
  •  2
  •   googletorp    16 年前

    看一看 Pinax 源可以在Github上找到。他们的项目站点经常使用通知 http://code.pinaxproject.com .

    编辑:
    我只是看了一下。Pinax似乎只需将其列在已安装的应用程序中,然后将其列在任何其他外部应用程序之前,并像通常那样包含其URL文件。

    推荐文章