收集静态文件引发错误配置 [英] Collecting staticfiles throws ImproperlyConfigured
问题描述
我正在使用Django 1.7。将站点部署到生产服务器并运行 collectstatic
时,出现以下错误消息:
django.core.exceptions。配置不当:STATICFILES_DIRS设置不应包含STATIC_ROOT设置
I'm using Django 1.7. When deploying my site to a Production server and running collectstatic
, I get following error message:
django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
我使用拆分设置;我的生产 local.py
包含:
I use split settings; my production local.py
contains:
STATIC_ROOT = '/home/username/projects/site/static/'
和我的 base.py
包含:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
推荐答案
a href = https://docs.djangoproject.com/zh-CN/1.7/ref/contrib/staticfiles/ rel = noreferrer> docs ,collectstatic会将文件从各个文件夹复制到STATIC_ROOT。
According to the docs, collectstatic will copy the files from various folders into STATIC_ROOT.
因此,您不能使用 STATICFILES_DIRS
中的 STATIC_ROOT
文件夹。
Therefore, you cannot use the STATIC_ROOT
folder in STATICFILES_DIRS
.
解决方案:将 STATIC_ROOT
更改为例如 STATIC_ROOT =’/ home / username / projects / site / assets /’
Solution: change STATIC_ROOT
to e.g. STATIC_ROOT = '/home/username/projects/site/assets/'
这篇关于收集静态文件引发错误配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!