[英]Adding a favicon to template on Django
I want to put a favicon in the base.html in my Django project, but it doesn't seems to work.我想在我的 Django 项目的 base.html 中放置一个图标,但它似乎不起作用。 It doesn't display any errors in the browser console, but I don't get the "GET" message in python manage.py runserver
console.它不会在浏览器控制台中显示任何错误,但我在python manage.py runserver
控制台中没有收到“GET”消息。
<link rel="icon" href="{% static 'assets/img/favicon.ico' %}"/>
Other static files such as JS and CSS are working just fine.其他静态文件如 JS 和 CSS 工作得很好。
You can check the configuration in settings.py您可以在 settings.py 中检查配置
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
And in your templates, put this line on the to top:在您的模板中,将此行放在顶部:
{% load staticfiles %}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.