Reputation: 123
I'm trying to link a css stylesheet to my django html template but it keeps being read as an html file with the error:
127.0.0.1/:1 Refused to apply style from 'http://127.0.0.1:8000/static_cdn/css/base-template.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
This is my base.html file and I know the path is correct because VS Code directs me to the file when I left-click on the link.
<head>
<link type="text/css" rel="stylesheet" href="../../static_cdn/css/base-template.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>GuitarShop</title>
</head>
Here is my directory:
Project Folder
guitarshop > templates > base.html
static_cdn > css > base-template.css
The reason why I am storing the css file in the static_cdn folder instead of a static folder in the templates folder is because when I do so, the command "python manage.py collectstatic" doesn't collect the file folder so I get the following error:
GET http://127.0.0.1:8000/static/base-template.css net::ERR_ABORTED 404 (Not Found)
Please help!
Upvotes: 0
Views: 425