0

我正在尝试将我的项目部署到heroku。一切正常,但没有静态文件。我得到这样的异常表单浏览器:

artyom-blog-v2.herokuapp.com/:1 Refused to apply style from 'https://artyom-blog-v2.herokuapp.com/static/bootstrap/dist/css/bootstrap.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
artyom-blog-v2.herokuapp.com/:9 GET https://artyom-blog-v2.herokuapp.com/static/jquery/dist/jquery.min.js net::ERR_ABORTED 404 (Not Found)
artyom-blog-v2.herokuapp.com/:10 GET https://artyom-blog-v2.herokuapp.com/static/bootstrap/dist/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)

代码:

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',
]
STATIC_URL = '/static/'
STATIC_DIR = BASE_DIR / 'posts' / 'static'

STATICFILES_DIRS = [STATIC_DIR]  # NEED
STATIC_ROOT = BASE_DIR / 'staticfiles'

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

如何解决?

4

0 回答 0