解决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/"),
]

posted @ 2019-06-10 09:32  如海  阅读(2687)  评论(0编辑  收藏  举报