[英]ImproperlyConfigured:You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path
I am new to django ! 我是django的新手! When I use the commad,
git push heroku master
I get this error. 当我使用commad,
git push heroku master
此错误。
remote: django.core.exceptions.ImproperlyConfigured: The STATICFILES_DIRS setting should not contain the STATIC_ROOT setting
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
My static files declarations are : 我的静态文件声明为:
STATIC_URL = '/static/'
# set for the Heroku deployment.
import dj_database_url
DATABASES = {
'default': dj_database_url.config(default='postgres://localhost')
}
#make reuqest.is_secure admit X-Forwarded-Proto
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# support all the host header
ALLOWED_HOSTS = ['*']
#static configuration
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
My requirements.txt/runtime.txt/Procfile are all good, I googled a lot, Even tried the whitenoise, still I cannot fix it, so can someone help me? 我的requirements.txt / runtime.txt / Procfile都很好,我在Google上搜索了很多,即使尝试了白噪声,还是无法解决,所以有人可以帮助我吗? Thanks a lot!
非常感谢!
My requirements.txt are like below: dj-database-url==0.4.2 我的requirements.txt如下所示:dj-database-url == 0.4.2
dj-static==0.0.6 dj-static == 0.0.6
Django==1.11.1 的Django = = 1.11.1
django-bootstrap3==8.2.3 django-bootstrap3 == 8.2.3
gunicorn==19.7.1 gunicorn == 19.7.1
pytz==2017.2 pytz == 2017.2
static3==0.7.0 静态3 == 0.7.0
IF I do heroku config:set DISABLE_COLLECTSTATIC=1
I can push successfully, but the blog page does not show out because of some error. 如果我执行
heroku config:set DISABLE_COLLECTSTATIC=1
我可以成功推送,但是由于某些错误,博客页面不会显示出来。
You have to put in settings File STATIC_ROOT
conf. 您必须输入设置文件
STATIC_ROOT
conf。 The best you can do in production is serve static files through amazon s3 or another cdn so you don't overload your server. 生产中最好的方法是通过Amazon s3或其他CDN提供静态文件,以免服务器超载。
See the Django static files docs for more information. 有关更多信息,请参见Django静态文件文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.