我想为favicon添加一个类似/favicon.ico的url。我的图片位于static/graphics/images/favicon.ico。我不想改变方向。我tried:- 你知道吗
from django.contrib import admin
from django.urls import path, include
from search import views
from django.views.generic.base import RedirectView
faviconI=RedirectView.as_view(url='/static/gr/favicon.ico')
urlpatterns = [
path('', views.Page, name='Home'),
path('favicon.ico/', faviconI, name="favicon")
]
但代码给出了一个重定向。我想从dir加载图像而不重定向
您可以使用django smart\u str方法从目录发送图像
相关问题 更多 >
编程相关推荐