搜尋

首頁  >  問答  >  主體

python - 為什麼專案無法推送到Heroku?

依照教學將專案推送到heroku,前面步驟一切順利沒有任何錯誤,直到這裡出現問題在網路上沒有找到解決方法。 。 。

感覺好像是setting.py的設定有問題,但跟教學裡對照是一樣的:

heroku的設定

if os.getcwd()=='/app':

import dj_database_url
DATABASES={
    'default':dj_database_url.config(default='postgres://localhost')
}

SECURY_PROXY_SSL_HEADER=('HTTP_X_FORWARDED_PROTO','https')

ALLOWED_HOSTS = ['*']

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

命令列的報錯:

(ll_env) G:python_dorest>heroku create
Creating app... done, protected-crag-1803
https://protected-crag-1803.h... | https://git .heroku.com/protec...

(ll_env) G:python_dorest>git push heroku master
Counting objects: 48, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (39/39), done .
Writing objects: 100% (48/48), 11.18 KiB | 0 bytes/s, done.
Total 48 (delta 3), reused 0 (delta 0)
remote: Compressing source files. .. done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.5.2

—————————中間內容省略—————————

remote:為 django-bootstrap3 執行 setup.py install:開始
remote:為 django-bootstrap3 執行 setup.py install:完成狀態「done」
remote:成功安裝 Django-1.11.2 dj - database-url-0.4.2 dj-static-0.0.6 django-bootstrap3-8.2.3 Gunicorn-19.7.1 psycopg2-2.7.1 pytz-2017.2 static3-0.7.0
remote:##remote: ----> $ python manage.pycollectstatic--noinput
remote:回溯(最近一次呼叫最後一次):
remote:檔案“manage.py”,第22行,在<模組>
remote中:execute_from_command_line( sys .argv)
remote:檔案“/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py”,第363行,在execute_from_command_line
remote :實用程式.execute()
remote:檔案“/app/.heroku/python/lib/python3.5/site-packages/django/core/management/__init__.py”,第355行,在execute
remote中: self.fetch_command(subcommand).run_from_argv(self.argv)
remote: 檔案「/app/.heroku/python/lib/python3.5/site-packages/django/core/management/base .py”,行283,在run_from_argv
remote: 檔案“/app/.heroku/python/lib/python3.5 /site-packages/django /core/management/base.py”,第330 行,在執行
remote: 輸出= self.handle(args, *options)
remote: 文件“/app/.heroku/ python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py”,第199 行,句柄
remote:collected = self.collect( )remote:檔案“/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py”,第124 行,在collect remote: handler(path, prefixed_pa​​th,儲存)
remote:檔案「/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic. py”,第354行,在copy_file
中遠端:如果不是self.delete_file(path, prefixed_pa​​th, source_storage):
remote: 檔案“/app/.heroku/python/lib/python3. 5/site-packages/django/contrib/staticfiles/management/commands/ collectstatic.py”,第260 行,delete_file
remote: if self.storage.exists(prefixed_pa​​th):
remote: File# 「/app/.heroku/python/lib/python3.5/site-packages/ django/core/files/storage.py",第392 行,存在
remote: return os.path.exists(self.path (name))
remote: File "/app/.heroku/python/ lib/python3.5/site-packages/django/contrib/staticfiles/storage.py",第50 行,路徑
remote: raise ImproperlyConfigured("您正在使用staticfiles 應用程式"
remote: django. core.exceptions.ImproperlyConfigured:您正在使用staticfiles 應用程序,而沒有將STATIC_ROOT 設定設為檔案系統路徑。
remote:
remote:
remote:!執行「$ python manage.pycollectstatic--noinput」時發生錯誤。
遠端:有關詳細信息,請參閱上面的回溯。
遠端:
遠端:您可能需要更新應用程式程式碼來解決此錯誤。
遠端:或者,您可以為此應用程式停用collectstatic:
遠端:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/...
remote: !推送被拒絕,無法編譯 Python 應用程式。
remote:
remote: !推送失敗
遠端:正在驗證部署...
遠端:
遠端:!推送到 protected-crag-1803 被拒絕。
remote:
To https://git.heroku.com/protec...
! [遠端拒絕]master-> master(預先接收掛鉤被拒絕)
錯誤:無法將一些引用推送到「https://git.heroku.com/protec...」

巴扎黑巴扎黑2700 天前890

全部回覆(1)我來回復

  • 淡淡烟草味

    淡淡烟草味2017-07-05 10:36:52

    好好看錯誤日誌:

    remote: File "/app/.heroku/python/lib/python3.5/site-packages/django/contrib/staticfiles/storage.py", line 50, 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.

    回覆
    0
  • 取消回覆