【问题标题】:How do i edit the favicon in the Browsable API in Django REST framework?如何在 Django REST 框架的 Browsable API 中编辑网站图标?
【发布时间】:2018-11-29 03:30:09
【问题描述】:

我需要编辑 Browsable API 的网站图标。
是否可以通过覆盖模板中的 api.html 来做到这一点?

【问题讨论】:

    标签: python django django-rest-framework


    【解决方案1】:

    这可以通过在 api.html 中添加以下块来实现

    {% block style %}
    {{ block.super }}
    <link rel="shortcut icon" type="image/png" href="xxxx.png" />
    {% endblock %}
    

    【讨论】:

      【解决方案2】:

      要扩展Arun's answer,您可以通过customizing the browsable API 设置网站图标。这意味着您在应用中创建api.html 的副本,然后添加指向您的网站图标的链接。

      在这个例子中,我有以下文件:

      • my_project
        • my_app
          • static
            • favicon.png
          • templates
            • rest_framework
              • api.html

      api.html 文件如下所示:

      {% extends "rest_framework/base.html" %}
      
      {% block style %}
      {{ block.super }}
      <link rel="shortcut icon" type="image/png" href="/static/portal/favicon.png" />
      {% endblock %}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-09-20
        • 2017-02-03
        • 1970-01-01
        • 1970-01-01
        • 2018-03-26
        相关资源
        最近更新 更多