重定向 favicon 的 url
项目的 urls.py
代码语言:javascript复制"""django2 URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import re_path # favicon.ico
from django.conf.urls import include
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views
from django.views.generic.base import RedirectView # favicon.ico
# favicon.ico
# favicon_view = RedirectView.as_view(re_path='/static/images/zhuo_64x64.ico', permanent=True) # django1.11
favicon_view = RedirectView.as_view(url='/static/images/zhuo_64x64.ico', permanent=True) # django2.2
# 定制站点头部和标题
admin.site.site_title = '博客后台管理系统' # 站点标题
admin.site.site_header = '博客后台管理系统' # 站点头部
urlpatterns = [
re_path(r'favicon.[ico|png]$', favicon_view), # favicon.ico
# re_path(r'favicon.png$', favicon_view), # favicon.ico
path('admin/', admin.site.urls),
path(r'ckeditor/', include('ckeditor_uploader.urls')),
] static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
在 base.html 修改
代码语言:javascript复制{% load static %}
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}">
favicon.ico
png 转 ico
http://www.easyicon.net/covert/