urls.py
urlpatterns = [
# ...
url(r'^favicon.ico$', MainApp_Views.favicon),
]
views.py
def favicon(request):
imgDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
imgDir = os.path.join(imgDir, 'common_static')
imgDir = os.path.join(imgDir, 'images')
imgFilePath = os.path.join(imgDir, 'favicon.ico')
# return HttpResponse('favicon...' + imgFilePath)
image_data = open(imgFilePath, "rb").read()
return HttpResponse(image_data, content_type="image/png") # 注意旧版的资料使用mimetype,现在已经改为content_type
urlpatterns = [
# ...
url(r'^favicon.ico$', MainApp_Views.favicon),
]
views.py
def favicon(request):
imgDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
imgDir = os.path.join(imgDir, 'common_static')
imgDir = os.path.join(imgDir, 'images')
imgFilePath = os.path.join(imgDir, 'favicon.ico')
# return HttpResponse('favicon...' + imgFilePath)
image_data = open(imgFilePath, "rb").read()
return HttpResponse(image_data, content_type="image/png") # 注意旧版的资料使用mimetype,现在已经改为content_type