[使用Django应用程序加载CSS的MIME类型问题

问题描述 投票:2回答:1

简单的问题-我在Heroku上托管了Django应用,但我的样式表未加载。现在,我已花时间阅读有关此问题的其他问题,但我相信每种情况都是独特的。现在错误如下:

Refused to apply style from 'https://mazzodjangoapp.herokuapp.com/static/blog/main.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

静态目录在我的setttings.py文件中定义为:

STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'

在我的base.html文件中,我的链接标记看起来像这样:

<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">

在本地工作。为什么不在Heroku环境中加载?谢谢,铁人

django heroku mime-types
1个回答
0
投票

我遇到了同样的问题。您需要先运行$ python manage.py collectstatic,然后再推动Heroku。希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.