実現したいこと
Server Error (500)が出ずに正常にWebアプリが表示されるようになる
発生している問題・分からないこと
Djangoで作成したWebアプリをrender.comを通じて、公開するときにserver Error(500)が表示される。
原因を調査し、改善しているが解決方法が不明。
以下ファイル構成である
salesproject
L accounts(フォルダ)
L sales(フォルダ)
L salesproject(フォルダ)
L settings.py
L template(フォルダ)
L build.sh
L manage.py
L render.yaml
L requirements.txt
エラーメッセージ
error
1Server Error (500)
該当のソースコード
settings.py
1import dj_database_url 2from pathlib import Path 3import os 4 5BASE_DIR = os.path.abspath(os.path.join(__file__, '../../../')) 6STATIC_URL = '/static/' 7 8SECRET_KEY = "django-insecure-)-k2$&e-nskyf_7cwr3uqqqnz3n%vsno$c9g_vv=kdi#*n&&gq" 9 10DEBUG = False 11 12ALLOWED_HOSTS = ["*"] 13# Application definition 14 15INSTALLED_APPS = [ 16 "django.contrib.admin", 17 "django.contrib.auth", 18 "django.contrib.contenttypes", 19 "django.contrib.sessions", 20 "django.contrib.messages", 21 "django.contrib.staticfiles", 22 "accounts.apps.AccountsConfig", 23 "sales.apps.SalesConfig", 24] 25 26MIDDLEWARE = [ 27 "django.middleware.security.SecurityMiddleware", 28 "django.contrib.sessions.middleware.SessionMiddleware", 29 "django.middleware.common.CommonMiddleware", 30 "django.middleware.csrf.CsrfViewMiddleware", 31 "django.contrib.auth.middleware.AuthenticationMiddleware", 32 "django.contrib.messages.middleware.MessageMiddleware", 33 "django.middleware.clickjacking.XFrameOptionsMiddleware", 34 "whitenoise.middleware.WhiteNoiseMiddleware", 35] 36 37ROOT_URLCONF = "salesproject.urls" 38 39TEMPLATES = [ 40 { 41 "BACKEND": "django.template.backends.django.DjangoTemplates", 42 "DIRS": [os.path.join(BASE_DIR, 'templates')], 43 "APP_DIRS": True, 44 "OPTIONS": { 45 "context_processors": [ 46 "django.template.context_processors.debug", 47 "django.template.context_processors.request", 48 "django.contrib.auth.context_processors.auth", 49 "django.contrib.messages.context_processors.messages", 50 ], 51 }, 52 }, 53] 54 55WSGI_APPLICATION = "salesproject.wsgi.application" 56 57DATABASES = { 58 "default": { 59 "ENGINE": "django.db.backends.sqlite3", 60 "NAME": os.path.join(BASE_DIR, 'db.sqlite3'), 61 } 62} 63 64if not DEBUG: 65 DATABASES = { 66 "default": dj_database_url.config ( 67 #Replace this value with your local database's connection string. 68 default = 'postgresql://postgres:postgres@localhost:5432/salesproject', 69 conn_max_age=600 70 ) 71} 72 73AUTH_PASSWORD_VALIDATORS = [ 74 { 75 "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", 76 }, 77 {"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",}, 78 {"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",}, 79 {"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",}, 80] 81 82LANGUAGE_CODE = "ja" 83 84TIME_ZONE = "Asia/Tokyo" 85 86USE_I18N = True 87 88USE_TZ = True 89 90 91if not DEBUG: 92 STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles") 93 STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" 94 95DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" 96 97AUTH_USER_MODEL = 'accounts.User' 98 99LOGIN_REDIRECT_URL = "index" 100LOGOUT_REDIRECT_URL = 'index'
build.sh
1set -o errexit 2pip install -r requirements.txt 3python3 manage.py collectstatic --no-input 4python3 manage.py migrate 5python3 manage.py superuser
render.yaml
1databases: 2 - name: mysitedb 3 plan: free 4 databaseName: sales 5 user: sales 6 7services: 8 - type: web 9 plan: free 10 name: salesproject 11 runtime: python 12 buildCommand: "./build.sh" 13 startCommand: "python -m gunicorn salesproject.asgi:application -k uvicorn.workers.UvicornWorker" 14 envVars: 15 - key: DATABASE_URL 16 fromDatabase: 17 name: mysitedb 18 property: connectionString 19 - key: WEB_CONCURRENCY 20 value: 4
試したこと・調べたこと
- teratailやGoogle等で検索した
- ソースコードを自分なりに変更した
- 知人に聞いた
- その他
上記の詳細・結果
settings.pyのDEBUG=Falseと変換し、ALLOWED_HOSTS = ["*"]と変換しましたが、Server Error (500)と出力されてしまいます
補足
特になし

あなたの回答
tips
プレビュー