在Linux环境下通过pytho manage.py collectstatic --settings=settings.local
命令收集静态资源的时候报错
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
如果有多个配置文件,则在指定的settings.local
文件中加入如下代码,或直接在settings.py
文件中直接加入
STATIC_URL = '/static/' # 能够访问静态文件的URL路径
STATIC_ROOT = os.path.join(BASE_DIR,'static')
STATIC_URL
是Django能够访问静态文件的URL路径
STATIC_ROOT
是collectstatic工具用来保存收集到的项目引用到任何静态文件的路径