簡體   English   中英

無法將網站圖標添加到我的 Django 應用程序

[英]Can not add favicon to my Django app

我正在使用 Django 2.06 開發應用程序。 我正在嘗試添加 Favicon,但它在我的應用程序中不起作用。

<link rel="shortcut icon" href="{% static 'favicon.ico' %}" type='image/x-icon' >
<link rel="icon" href="{% static 'favicon.ico' %}" type='image/x-icon'>

我也在base.html文件中提到了{% load static %}

from django.urls import path
from . import views
from django.conf import settings
from django.conf.urls.static import static
from .views import HomeView, article_details, ArticleListView, 
 ProductPageView, ContactPageView 

urlpatterns = [
    path('', HomeView.as_view(), name='home'), 
    path('details/<int:id>/<slug:slug>', article_details, name='article-details'),
    path('articles/', ArticleListView.as_view(), name='article-list-view'),
    path('products/', ProductPageView.as_view(), name='product-page-view'), 
    path('contact/', ContactPageView.as_view(), name='contact-page-view'), 
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

我運行了鏈接,但它不起作用..

'favicon\favicon.ico' could not be found
http://localhost:8000/static/favicon/favicon.ico

對於有此問題的每個人:

首先檢查鏈接是否有效(即:localhost:8000/static/images/favicon.ico)

如果鏈接有效並且您實際上可以看到您的圖標,則意味着您的收藏夾圖標尚未顯示的唯一原因是您的導航器緩存。

重新啟動您的導航器(Chrome、Firefox、Safari 等),當您再次打開它時,您應該能夠看到它已更新。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM