【发布时间】:2018-11-29 03:30:09
【问题描述】:
我需要编辑 Browsable API 的网站图标。
是否可以通过覆盖模板中的 api.html 来做到这一点?
【问题讨论】:
标签: python django django-rest-framework
我需要编辑 Browsable API 的网站图标。
是否可以通过覆盖模板中的 api.html 来做到这一点?
【问题讨论】:
标签: python django django-rest-framework
这可以通过在 api.html 中添加以下块来实现
{% block style %}
{{ block.super }}
<link rel="shortcut icon" type="image/png" href="xxxx.png" />
{% endblock %}
【讨论】:
要扩展Arun's answer,您可以通过customizing the browsable API 设置网站图标。这意味着您在应用中创建api.html 的副本,然后添加指向您的网站图标的链接。
在这个例子中,我有以下文件:
my_project
my_app
static
favicon.pngtemplates
rest_framework
api.htmlapi.html 文件如下所示:
{% extends "rest_framework/base.html" %}
{% block style %}
{{ block.super }}
<link rel="shortcut icon" type="image/png" href="/static/portal/favicon.png" />
{% endblock %}
【讨论】: