前提・実現したいこと
djangoで作成したアプリケーションを
Herokuでデプロイしたいと考えています。
発生している問題
Server Error (500)が表示される
エラーメッセージ
terminal
1# heroku logsを実行した時の出力 22019-06-23T13:59:43.387530+00:00 app[web.1]: raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name) 32019-06-23T13:59:43.387532+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'haiki_point_app/vendor/fontawesome-free/css/all.min.css'
該当のソースコード
tree
1haiki_point_dir 2├── haiki_point_app 3│ ├── __pycache__ 4│ ├── migrations 5│ │ └── __pycache__ 6│ ├── static 7│ │ └── haiki_point_app 8│ │ ├── css 9│ │ ├── img 10│ │ ├── js 11│ │ │ └── demo 12│ │ ├── scss 13│ │ │ ├── navs 14│ │ │ └── utilities 15│ │ └── vendor 16│ │ ├── bootstrap 17│ │ │ ├── js 18│ │ │ └── scss 19│ │ │ ├── mixins 20│ │ │ ├── utilities 21│ │ │ └── vendor 22│ │ ├── chart.js 23│ │ ├── datatables 24│ │ ├── fontawesome-free 25│ │ │ ├── css 26│ │ │ ├── js 27│ │ │ ├── less 28│ │ │ ├── scss 29│ │ │ ├── sprites 30│ │ │ ├── svgs 31│ │ │ │ ├── brands 32│ │ │ │ ├── regular 33│ │ │ │ └── solid 34│ │ │ └── webfonts 35│ │ ├── jquery 36│ │ └── jquery-easing 37│ └── templates 38│ └── haiki_point_app 39├── haiki_point_dir # setting.pyが入っている 40│ └── __pycache__ 41└── staticfiles 42 ├── admin 43 │ ├── css 44 │ │ └── vendor 45 │ │ └── select2 46 │ ├── fonts 47 │ ├── img 48 │ │ └── gis 49 │ └── js 50 │ ├── admin 51 │ └── vendor 52 │ ├── jquery 53 │ ├── select2 54 │ │ └── i18n 55 │ └── xregexp 56 └── haiki_point_app 57 ├── css 58 ├── img 59 ├── js 60 │ └── demo 61 ├── scss 62 │ ├── navs 63 │ └── utilities 64 └── vendor 65 ├── bootstrap 66 │ ├── js 67 │ └── scss 68 │ ├── mixins 69 │ ├── utilities 70 │ └── vendor 71 ├── chart.js 72 ├── datatables 73 ├── fontawesome-free 74 │ ├── css 75 │ ├── js 76 │ ├── less 77 │ ├── scss 78 │ ├── sprites 79 │ ├── svgs 80 │ │ ├── brands 81 │ │ ├── regular 82 │ │ └── solid 83 │ └── webfonts 84 ├── jquery 85 └── jquery-easing 86
settings.py
python
1 2# 一部抜粋 3BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 4 5DEBUG = False 6 7ALLOWED_HOSTS = ["*"] 8 9MIDDLEWARE = [ 10 'django.middleware.security.SecurityMiddleware', 11 'whitenoise.middleware.WhiteNoiseMiddleware', 12 'django.contrib.sessions.middleware.SessionMiddleware', 13 'django.middleware.common.CommonMiddleware', 14 'django.middleware.csrf.CsrfViewMiddleware', 15 'django.contrib.auth.middleware.AuthenticationMiddleware', 16 'django.contrib.messages.middleware.MessageMiddleware', 17 'django.middleware.clickjacking.XFrameOptionsMiddleware', 18] 19 20STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') 21 22STATIC_URL = '/static/' # localのstaticフォルダ 23 24STATICFILES_DIRS = ( 25 os.path.join(BASE_DIR, 'haiki_point_app/static'), 26) 27 28#STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 29#STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' 30STATICFILES_STORAGE = 'haiki_point_dir.storage.WhiteNoiseStaticFilesStorage' 31 32STATICFILES_FINDERS = ( 33 'django.contrib.staticfiles.finders.FileSystemFinder', 34) 35 36try: 37 from .local_settings import * 38except ImportError: 39 pass 40 41if not DEBUG: 42 SECRET_KEY = os.environ['SECRET_KEY'] 43 import django_heroku 44 django_heroku.settings(locals())
storage.py
python
1from whitenoise.storage import CompressedManifestStaticFilesStorage 2 3class WhiteNoiseStaticFilesStorage(CompressedManifestStaticFilesStorage): 4 manifest_strict = False 5
wsgi.py
python
1import os 2 3from django.core.wsgi import get_wsgi_application 4 5os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'haiki_point_dir.settings') 6 7application = get_wsgi_application()
テンプレートでのstaticファイルの参照
html
1<link href="{% static 'haiki_point_app/vendor/fontawesome-free/css/all.min.css' %}" rel="stylesheet" type="text/css">
requirements.txt
txt
1dj-database-url==0.5.0 2Django==2.2.2 3django-heroku==0.3.1 4gunicorn==19.9.0 5psycopg2==2.8.3 6pytz==2019.1 7sqlparse==0.3.0 8whitenoise==4.1.2
herokuのconfig
terminal
1=== haiki-app Config Vars 2DATABASE_URL: postgres://~.compute-1.amazonaws.com:5432/*** 3DEBUG_COLLECTSTATIC: 0 4DISABLE_COLLECTSTATIC: 0 5LOG_LEVEL: DEBUG 6SECRET_KEY: *** 7
補足情報(FW/ツールのバージョンなど)
Python 3.7.3
Django 2.2.2
heroku 7.25.0 linux-x64 node-v11.14.0
試したこと
以下のようにtemplateタグを使わない場合、Errorは出ないがstaticファイルは反映されない。
html
1<link href="/static/haiki_point_app/vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
STATICFILES_STORAGEは以下の3種類と定義しない場合を確認したが結果は変わらなかった。
python
1STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' 2STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' 3STATICFILES_STORAGE = 'haiki_point_dir.storage.WhiteNoiseStaticFilesStorage'
local環境では問題なく実行され、staticファイルも反映されます。
以上が自分なりに試したことです。
エラーメッセージを検索し、丸1日試行錯誤したのですが解決できませんでした。
どなたか解決方法をご教授お願いいたします。
またご不明点などがありましたら、ご連絡いただければ幸いです。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/07 07:44