【问题标题】:How do I customize the notification message in django-oscar notification system如何在 django-oscar 通知系统中自定义通知消息
【发布时间】:2019-01-13 23:35:50
【问题描述】:

如何自定义账户/通知中显示的通知消息

此页面上缺少某些内容,通知正文显示如下:-

<a href="/catalogue/test-product_6/">test product</a> 有货了

而不是产品的可点击链接

我尝试编辑 message.html 模板,但没有发生任何变化

我只需要在模板customer/notifications/detail.html中知道 {{ notification.body }} 来自哪个模板?

我应该怎么做才能修复这个链接

注意:发送给用户的电子邮件获得了正确的链接,我可以通过数据库中的通信事件对其进行自定义 是否也有任何选项可以自定义数据库中的通知模板?

提前致谢

【问题讨论】:

    标签: django-oscar


    【解决方案1】:

    如您所说,通知是从customer/notifications/detail.html 呈现的。

    问题是通知正文传递了 HTML,但模板是 rendering it as an unsafe string(即,HTML 被转义)。

    这看起来像是 Oscar 中的一个错误,我为此创建了一个 issue

    与此同时,您需要覆盖此模板来更改它:

    <td>{{ notification.body }}</td>
    

    到:

    <td>{{ notification.body|safe }}</td>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      • 1970-01-01
      • 2015-12-19
      • 2020-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多