原因:
settings.py 未配置静态资源位置
urls.py 未配置相应路由
解决方法:
在项目目录下新建 static用于存放静态文件
1 settings.py
2
3 STATIC_URL = 'static/'
4 STATICFILES_DIRS = [
5 BASE_DIR / "static",
6 ]
7 STATIC_ROOT = os.path.join(BASE_DIR, "STATIC")
urls.py
from django.conf.urls import url
from django.views.static import serve
from yshop.settings import STATIC_ROOT
url(r'^static/(?P<path>.*)$', serve, {"document_root": STATIC_ROOT}),