解决Django项目静态资源无法访问的问题
静态资源无法访问
url.py
中配置
from django.conf.urls import url
from django.views import static
from django.conf import settings
然后在urlpatterns
中添加:
url(r'^static/(?P<path>.*)$', static.serve, {'document_root': settings.STATIC_ROOT}, name='static')
settings.py
文件设置
STATIC_URL = '/static/'
STATIC_ROOT = 'static'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "/static/"),
]