raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name) ValueError: Missing staticfiles manifest entry for 'favicon.png' when DEBUG = False
我只在 DEBUG = False 时收到此错误,当 DEBUG = True 时我没有收到任何错误
要在保持 DEBUG = False 的同时解决此问题,我必须将 favicon.png(我已经删除了一段时间)添加回 static_root 文件夹,然后运行 python manage.py collectstatic
我检查了所有文件,所有 html 文档都将链接 favicon.png 行注释掉,所以这不是问题。
settings.py 有以下内容:
STATIC_URL = '/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR, 'static_root'),
]
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
urls.py 有以下内容:
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)