我是django的新手!当我使用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
我的静态文件声明是:
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了很多,甚至试过了whitenoise,我仍然无法解决它,所以有人能帮帮我吗?非常感谢!
我的requirements.txt如下: DJ-数据库-URL == 0.4.2
DJ静电== 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
我可以成功推送,但由于某些错误,博客页面没有显示出来。
答案 0 :(得分:0)
您必须设置文件STATIC_ROOT
conf。你可以在制作中做的最好的事情是通过亚马逊s3或其他cdn提供静态文件,这样你就不会使服务器过载。