初めてWebアプリケーションを作成しているのですが、herokuにデプロイまで出来たのですが、heroku openで開くとServer Error (500)としか出力しなく、解決方法が分からなくて困っています。
heroku run python manage.py migrateとheroku run python manage.py createsuperuserは済んでいます。
heroku logsで確認しても特に異常は見られません。
また、ローカル環境では問題なく動いています。
以下の記事を参考にしたのですが上手くいきません。
リンク内容
教えていただけないでしょうか?
#追加
テンプレートの下記のbase.htmlのstaticとつく部分を削除したら、静的ファイルは読みませんがhtmlの出力が出るようになりました
静的ファイルの扱い方が悪いのでしょうか?
base
1{% load static %} 2 3<!DOCTYPE html> 4<html lang="en" dir="ltr"> 5 <head> 6 <meta charset="utf-8"> 7 8 **ここから** 9 <link rel="stylesheet" href="{% static 'css/base.css' %}"> 10 <link rel="stylesheet" href="{% static 'css/ress.css' %}"> 11 <link rel="stylesheet" href="{% static 'css/slick.css' %}"> 12 <link rel="stylesheet" href="{% static 'css/slick-theme.css' %}"> 13 **ここまでが不具合** 14 15 <!--cdn方式での読み込み--> 16 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> 17 <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"> 18 </head> 19 <body> 20 <div id="wrapper"> 21 {% include 'navi.html' %} 22 <main> 23 {% block content %} 24 {% endblock %} 25 </main> 26 <footer> 27 <ul> 28 <li><a href="{% url 'index' %}">Home</a></li> 29 <li><a href="{% url 'about' %}">このサイトについて</a></li> 30 <li><a href="{% url 'agree' %}">利用規約</a></li> 31 <li><a href="{% url 'privacy' %}">プライバシー</a></li> 32 </ul> 33 </footer> 34 35 **ここから** 36 <script src="{% static 'js/jquery.raty.js' %}"></script> 37 <script src="{% static 'js/slick.min.js' %}"></script> 38 <script src="{% static 'js/script.js' %}"></script> 39 **ここまで不具合** 40 41 </div> 42 </body> 43</html> 44
herokulogs
12020-03-27T02:29:17.337989+00:00 app[web.1]: 10.28.44.109 - - [27/Mar/2020:11:29:17 +0900] "GET / HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36" 22020-03-27T02:29:17.668818+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=udonmap.herokuapp.com request_id=362e1e06-aa83-4e45-b019-1b30dfa6105f fwd="121.82.75.219" dyno=web.1 connect=0ms service=5ms status=404 bytes=266 protocol=https 32020-03-27T02:29:17.668873+00:00 app[web.1]: 10.28.44.109 - - [27/Mar/2020:11:29:17 +0900] "GET /favicon.ico HTTP/1.1" 404 85 "https://udonmap.herokuapp.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
settings
1import os 2 3BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 5DEBUG = False 6 7ALLOWED_HOSTS = ['*'] 8 9# Application definition 10 11INSTALLED_APPS = [ 12 'map', 13 'accounts', 14 'django.contrib.admin', 15 'django.contrib.auth', 16 'django.contrib.contenttypes', 17 'django.contrib.sessions', 18 'django.contrib.messages', 19 'django.contrib.staticfiles', 20] 21 22MIDDLEWARE = [ 23 'django.middleware.security.SecurityMiddleware', 24 'django.contrib.sessions.middleware.SessionMiddleware', 25 'django.middleware.common.CommonMiddleware', 26 'django.middleware.csrf.CsrfViewMiddleware', 27 'django.contrib.auth.middleware.AuthenticationMiddleware', 28 'django.contrib.messages.middleware.MessageMiddleware', 29 'django.middleware.clickjacking.XFrameOptionsMiddleware', 30 'whitenoise.middleware.WhiteNoiseMiddleware', 31] 32 33ROOT_URLCONF = 'myudonnmap.urls' 34 35TEMPLATES = [ 36 { 37 'BACKEND': 'django.template.backends.django.DjangoTemplates', 38 'DIRS': [ 39 os.path.join(BASE_DIR, 'templates'), 40 ], 41 'APP_DIRS': True, 42 'OPTIONS': { 43 'context_processors': [ 44 'django.template.context_processors.debug', 45 'django.template.context_processors.request', 46 'django.contrib.auth.context_processors.auth', 47 'django.contrib.messages.context_processors.messages', 48 'social_django.context_processors.backends', 49 'social_django.context_processors.login_redirect', 50 'map.context_processors.common', 51 ], 52 }, 53 }, 54] 55 56WSGI_APPLICATION = 'myudonmap.wsgi.application' 57 58 59# Database 60# https://docs.djangoproject.com/en/2.0/ref/settings/#databases 61import dj_database_url 62import pymysql 63pymysql.install_as_MySQLdb() 64 65DATABASES = { 66 'default': { 67 'ENGINE': 'django.db.backends.mysql', 68 'NAME': 'myudonmap', 69 'USER': 'root', 70 'PASSWORD': 'fcgpr3fc', 71 'HOST': '', 72 'PORT': '', 73 } 74} 75 76 77# Password validation 78# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators 79 80AUTH_PASSWORD_VALIDATORS = [ 81 { 82 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 83 }, 84 { 85 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', 86 }, 87 { 88 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', 89 }, 90 { 91 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', 92 }, 93] 94 95 96# Internationalization 97# https://docs.djangoproject.com/en/2.0/topics/i18n/ 98 99LANGUAGE_CODE = 'ja' 100 101TIME_ZONE = 'Asia/Tokyo' 102 103USE_I18N = True 104 105USE_L10N = True 106 107USE_TZ = True 108 109 110# Static files (CSS, JavaScript, Images) 111# https://docs.djangoproject.com/en/2.0/howto/static-files/ 112 113STATIC_URL = '/static/' 114STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 115STATICFILES_DIRS = [ 116 os.path.join(BASE_DIR, "static"), 117] 118 119MEDIA_URL = '/media/' 120MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 121 122LOGIN_REDIRECT_URL = '/' 123 124AUTH_USER_MODEL = 'accounts.CustomUser' 125 126try: 127 from .local_settings import * 128except ImportError: 129 pass 130 131if not DEBUG: 132 SECRET_KEY = os.environ['SECRET_KEY'] 133 import django_heroku 134 django_heroku.settings(locals()) 135 136db_from_env = dj_database_url.config(conn_max_age=600, ssl_require=True) 137DATABASES['default'].update(db_from_env)
localsettings
1import os 2 3SECRET_KEY = 'v6k5+qtuf0!y3ing^n4hhf&fkc&za*nq^vz8^#%=fmxoz%9num' 4 5BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 6 7DATABASES = { 8 'default': { 9 'ENGINE': 'django.db.backends.mysql', 10 'NAME': 'mymap', 11 'USER': 'root', 12 'PASSWORD': 'fcgpr3fc', 13 'HOST': '', 14 'PORT': '', 15 } 16} 17 18DEBUG = True
wsgi
1import os 2 3from django.core.wsgi import get_wsgi_application 4 5os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myudonmap.settings") 6 7application = get_wsgi_application() 8 9from whitenoise.django import DjangoWhiteNoise 10application = DjangoWhiteNoise(application)
gitginore
1__pycache__ 2db.sqlite3 3.DS_Store 4local_settings.py
Profile
1web: gunicorn myudonmap.wsgi --log-file -
requirements
1asn1crypto==1.3.0 2branca==0.4.0 3certifi==2019.11.28 4cffi==1.14.0 5chardet==3.0.4 6chromedriver-binary==81.0.4044.20.0 7cryptography==2.8 8cycler==0.10.0 9defusedxml==0.6.0 10dj-database-url==0.5.0 11Django==2.0.5 12django-allauth==0.41.0 13django-appconf==1.0.3 14django-braces==1.14.0 15django-imagekit==4.0.2 16django-model-utils==4.0.0 17django-star-ratings==0.9.1 18django-stdimage==5.0.2 19django_heroku 20et-xmlfile==1.0.1 21flickrapi==2.4.0 22folium==0.10.1 23gunicorn==19.8.1 24Jinja2==2.11.1 25kiwisolver==1.1.0 26MarkupSafe==1.1.1 27mysqlclient==1.4.6 28oauthlib==2.0.6 29openpyxl==3.0.3 30pilkit==2.0 31Pillow==7.0.0 32progressbar2==3.50.0 33pycosat==0.6.3 34pycparser==2.19 35PyJWT==1.7.1 36PyMySQL==0.9.3 37pyOpenSSL==19.1.0 38pyparsing==2.4.6 39PySocks==1.7.1 40python-dateutil==2.8.1 41python-utils==2.4.0 42python3-openid==3.1.0 43pytz==2019.3 44requests==2.22.0 45requests-oauthlib==0.8.0 46requests-toolbelt==0.8.0 47ruamel-yaml==0.15.87 48six==1.14.0 49social-auth-app-django==3.1.0 50social-auth-core==3.2.0 51soupsieve==1.9.5 52swapper==1.1.2.post1 53tqdm==4.42.1 54urllib3==1.25.8 55whitenoise==3.3.1 56xlrd==1.2.0 57xlwt==1.3.0
runtime
1python-3.6.10
回答1件
あなたの回答
tips
プレビュー