Django Herokuでcss読まれない

ローカルではcss(staticファイル)読めているのに、デプロイ先(Heroku)では読み込まれない

settings.pyにこんな感じに記述しているのにだめ

# Static asset configuration
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

解決方法

僕はこの方法で解決した

whitenoiseのインストール

pip install whitenoise

wsgi.pyの変更 一番最後に(importは適当な位置に)

from whitenoise.django import DjangoWhiteNoise

application = DjangoWhiteNoise(application)

Djangoのバージョン

Django==2.0.7