python3.6+django2.2
1. 修改项目的setting.py
STATIC_URL = '/static/' STATIC_ROOT = 'static' ## 新增行 STATICFILES_DIRS = [ os.path.join(BASE_DIR,'/static/'), # os.path.join(BASE_DIR,'log_analysis/log_analysis_static/'), ]
2. 修改urls.py:
from django.conf import settings from django.conf.urls import url, include # path('', include('user.urls')),(增加以下url) url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static'), ]
重启服务器,解决问题