簡體   English   中英

在 Heroku 上部署 Django 應用程序需要支持

[英]Support needed for Django app deployment on Heroku

我有一個應用程序,我想在 Heroku 上部署。尚未完成,但現在是我老師的要求。 我在 heroku 上創建了一個帳戶和應用程序並使用 GitHub 部署方法但是當我單擊部署分支時出現以下類型的錯誤:

 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_0f3c3e792cd2015b5d316aad8cf28d6c/static'
 !     Error while running '$ python manage.py collectstatic --noinput'.
       See traceback above for details.
       You may need to update application code to resolve this error.
       Or, you can disable collectstatic for this application:
          $ heroku config:set DISABLE_COLLECTSTATIC=1
       https://devcenter.heroku.com/articles/django-assets
 !     Push rejected, 

你能幫我理解錯誤並解決它嗎?

如果可能的話,我想使用這種部署方法,因為我也是 git 的初學者,我想暫時避免使用 CLI。

謝謝,

編輯:根據需要粘貼 Requirements.txt:

asgiref==3.2.3
Brotli==1.0.7
certifi==2020.4.5.1
chardet==3.0.4
dj-database-url==0.5.0
Django==3.0.3
django-crispy-forms==1.9.0
django-heroku==0.3.1
gunicorn==20.0.4
idna==2.9
psycopg2==2.8.5
pytz==2019.3
requests==2.23.0
six==1.14.0
sqlparse==0.3.0
urllib3==1.25.9
whitenoise==5.0.1

我不知道您的設置的 state 是什么,但請確保您的 static 網址都是在settings.py中創建的。 特別是STATICFILES_DIRS ,它將設置一個位置來收集用於生產的靜態信息。

請關注此 Heroku KB: https://devcenter.heroku.com/articles/django-assets |

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

# Extra places for collectstatic to find static files.
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

然后它應該在正確的文件夾中收集 static。 讓我知道。

請使用whitenoise在 heroku 上部署 static 個文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM