1. 配置 settings.py 静态路径
STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static')
2. 打开命令行,进入项目目录,执行命令将静态文件输出至 \static 目录
python manage.py collectstatic
3. 配置 url 匹配,打开 urls.py 增加下面语句
from django.conf import settings from django.views.static import serve urlpatterns = [ …… url(r'^static/(?P<path>.*)$', serve, {'document_root': settings.STATIC_ROOT}), ]
评论列表,共 0 条评论
暂无评论