【问题标题】:ImproperlyConfigured:You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path配置不当:您正在使用静态文件应用程序而没有将 STATIC_ROOT 设置设置为文件系统路径
【发布时间】:2017-07-15 02:13:49
【问题描述】:

我是 django 的新手!当我使用逗号时,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

我的静态文件声明是:

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'),
)

我的 requirements.txt/runtime.txt/Procfile 都很好,我google了很多,即使尝试了白噪声,我仍然无法修复它,所以有人可以帮助我吗?非常感谢!

我的 requirements.txt 如下: dj-database-url==0.4.2

dj-static==0.0.6

Django==1.11.1

django-bootstrap3==8.2.3

gunicorn==19.7.1

pytz==2017.2

static3==0.7.0

如果我这样做了heroku config:set DISABLE_COLLECTSTATIC=1 可以推送成功,但是因为一些错误,博客页面没有显示出来。

【问题讨论】:

    标签: python django


    【解决方案1】:

    您必须输入设置文件STATIC_ROOT conf。您可以在生产中做的最好的事情是通过 amazon s3 或其他 cdn 提供静态文件,这样您就不会超载服务器。

    See the Django static files docs for more information.

    【讨论】:

      猜你喜欢
      • 2018-07-05
      • 2020-07-28
      • 2020-07-20
      • 2016-08-14
      • 2018-09-04
      • 1970-01-01
      • 2015-03-18
      • 1970-01-01
      • 2020-08-02
      相关资源
      最近更新 更多