Django推送到heroku出错heroku config:set DISABLE_COLLECTSTATIC=1

参考资料:https://segmentfault.com/q/1010000010016708

出现以下错误

remote: -----> $ python manage.py collectstatic --noinput
remote:        Traceback (most recent call last):
remote:          File "manage.py", line 15, in <module>
remote:            execute_from_command_line(sys.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
remote:            utility.execute()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
remote:            self.fetch_command(subcommand).run_from_argv(self.argv)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
remote:            self.execute(*args, **cmd_options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 335, in execute
remote:            output = self.handle(*args, **options)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 189, in handle
remote:            collected = self.collect()
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 114, in collect
remote:            handler(path, prefixed_path, storage)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 344, in copy_file
remote:            if not self.delete_file(path, prefixed_path, source_storage):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 250, in delete_file
remote:            if self.storage.exists(prefixed_path):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/files/storage.py", line 308, in exists
remote:            return os.path.exists(self.path(name))
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 43, in path
remote:            raise ImproperlyConfigured("You're using the staticfiles app "
remote:        django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
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
remote:
remote:        https://devcenter.heroku.com/articles/django-assets
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to desolate-caverns-46945.
remote:
To https://git.heroku.com/desolate-caverns-46945.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/desolate-caverns-46945.git'

解决方法:

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


显示可能是heroku服务器已经有一个静态文件占位了,所以要删掉它。
执行命令:heroku config:set DISABLE_COLLECTSTATIC=0

我也遇到了同样的问题,用这种方法解决了,希望能帮助你和后来者~

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
基于python3.8和Django3.0的博客 文章,页面,分类目录,标签的添加,删除,编辑等。文章及页面支持Markdown,支持代码高亮。 支持文章全文搜索。 完整的评论功能,包括发表回复评论,以及评论的邮件提醒,支持Markdown。 侧边栏功能,最新文章,最多阅读,标签云等。 支持Oauth登陆,现已有Google,GitHub,facebook,微博,QQ登录。 支持Memcache缓存,支持缓存自动刷新。 简单的SEO功能,新建文章等会自动通知Google和百度。 集成了简单的图床功能。 集成django-compressor,自动压缩css,js。 网站异常邮件提醒,若有未捕捉到的异常会自动发送提醒邮件。 集成了微信公众号功能,现在可以使用微信公众号来管理你的vps了。 安装 mysql客户端从pymysql修改成了mysqlclient,具体请参考 pypi 查看安装前的准备。 使用pip安装: pip install -Ur requirements.txt 如果你没有pip,使用如下方式安装: OS X / Linux 电脑,终端下执行: curl http://peak.telecommunity.com/dist/ez_setup.py | python curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python Windows电脑: 下载 http://peak.telecommunity.com/dist/ez_setup.py 和 https://raw.github.com/pypa/pip/master/contrib/get-pip.py 这两个文件,双击运行。 配置 配置都是在 setting.py 中,部分配置迁移到了后台配置中。 很多 setting 配置我都是写在环境变量里面的.并没有提交到 github 中来.例如SECRET_KEY,OAHUTH,mysql以及邮件部分的配置等.你可以直接修改代码成你自己的,或者在环境变量里面加入对应的配置就可以了. test目录中的文件都是为了travis自动化测试使用的.不用去关注.或者直接使用.这样就可以集成travis自动化测试了. bin目录是在linux环境中使用Nginx+Gunicorn+virtualenv+supervisor来部署的脚本和Nginx配置文件.可以参考我的文章: DjangoBlog部署教程 有详细的部署介绍. 运行 修改DjangoBlog/setting.py 修改数据库配置,如下所示: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'djangoblog', 'USER': 'root', 'PASSWORD': 'password', 'HOST': 'host', 'PORT': 3306, } } 创建数据库 mysql数据库中执行: CREATE DATABASE `djangoblog` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci */; 然后终端下执行: ./manage.py makemigrations ./manage.py migrate 注意: 在使用 ./manage.py 之前需要确定你系统中的 python 命令是指向 python 3.6 及以上版本的。如果不是如此,请使用以下两种方式中的一种: 修改 manage.py 第一行 #!/usr/bin/env python 为 #!/usr/bin/env python3 直接使用 python3 ./manage.py makemigrations 创建超级用户 终端下执行: ./manage.py createsuperuser 创建测试数据 终端下执行: ./manage.py create_testdata 收集静态文件 终端下执行: ./manage.py collectstatic --noinput ./manage.py compress --force 开始运行: 执行: ./manage.py runserver 浏览器打开: http://127.0.0.1:8000/ 就可以看到效果了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值