【问题标题】:How do I reference my site's title in a template?如何在模板中引用我网站的标题?
【发布时间】:2018-07-10 22:35:28
【问题描述】:

我正在创建 Wagtail 网站。在管理部分,我转到设置>>站点>>本地主机,并将“站点名称”设置为“我的第一个 Wagtail 站点”。

如何使用 Django 代码在模板中显示网站标题?

【问题讨论】:

    标签: wagtail


    【解决方案1】:

    要使用的标签是:

    {{ request.site.site_name }}
    

    【讨论】:

      【解决方案2】:

      旧版本

      <h1>Welcome to the {{ request.site.site_name }} website!</h1>
      

      新版本

      {% load wagtailcore_tags %}
      {% wagtail_site as current_site %}
      
      <h1>Welcome to the {{ current_site.site_name }} website!</h1>
      

      参考:https://docs.wagtail.io/en/stable/releases/2.9.html#upgrade-considerations

      【讨论】:

        猜你喜欢
        • 2020-06-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-29
        • 2022-01-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多