我已將我的 django 應用程式部署到 heroku,并且我正在Internal Server Error訪問該網站。
設定.py:
'ALLOWED_HOSTS = ['http://127.0.0.1:8000/','https://stripetestdjango.herokuapp.com/', 'localhost']
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
MEDIA_URL = '/images/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_ROOT = BASE_DIR / 'static/images'
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
# STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
if os.getcwd() == '/app':
DEBUG = False
heroku 日志顯示如下:

我有 .env 檔案。如何將其推送到服務器以及我正在使用 heroku 進行部署。我猜錯誤是它無法找到我的 .env 檔案。
如果需要,請隨時詢問更多詳細資訊。
uj5u.com熱心網友回復:
您永遠不應該推送.env包含敏感資料(即 SECRET_KEY_STRIPE)的檔案,而應該使用
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/318876.html
