解决Django项目静态资源无法访问的问题

静态资源无法访问

url.py中配置

from django.conf.urls import url
from django.views import static
from django.conf import settings

然后在urlpatterns 中添加:

url(r'^static/(?P.*)$', 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/"),
]

转载于:https://www.cnblogs.com/ruhai/p/10996030.html

你可能感兴趣的:(python,开发工具,操作系统)