简体   繁体   English

Django:拒绝从...应用样式,因为它的 MIME 类型('text/html')不是受支持的样式表 MIME 类型

[英]Django: Refused to apply style from ... because its MIME type ('text/html') is not a supported stylesheet MIME type

i am trying to connet my style.css in django template using the static files {% static 'assets/css/style.css' %} but i keep seeing this error Refused to apply style from 'http://127.0.0.1:8000/assets/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.我正在尝试使用静态文件{% static 'assets/css/style.css' %}在 django 模板中连接我的style.css ,但我一直看到此错误Refused to apply style from 'http://127.0.0.1:8000/assets/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled. . . NOTE : when i copy my css and manually paste it in a style tag inside the section everything works fine, but my css have over 23,000 lines of code and it's too much to be sitting in the head section of my project.注意:当我复制我的 css 并将其手动粘贴到该部分内的样式标记中时,一切正常,但我的 css 有超过 23,000 行代码,并且坐在我项目的头部部分太多了。 Please how do i go about fixing this error.请问我该如何解决这个错误。

index.html索引.html

{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <!-- Favicon -->
    <link rel="shortcut icon" href="{% static 'assets/images/favicon.ico' %}">

    <!-- Google Font -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap">

    <!-- Plugins CSS -->
    <link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/font-awesome/css/all.min.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/bootstrap-icons/bootstrap-icons.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/tiny-slider/tiny-slider.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/glightbox/css/glightbox.css' %}">

    <!-- Theme CSS -->
    <link id="style-switch" rel="stylesheet" type="text/css" href="{% static '/assets/css/style.css' %}">
</head>

tree

├───base
│   ├───migrations
│   │   └───__pycache__
│   └───__pycache__
├───course
│   ├───migrations
│   │   └───__pycache__
│   ├───templatetags
│   │   └───__pycache__
│   └───__pycache__
├───dashboard
│   ├───migrations
│   │   └───__pycache__
│   └───__pycache__
├───dexxaedprj
│   └───__pycache__
├───static
│   ├───assets
│   │   ├───css
│   │   │   ├───components
│   │   │   │   └───vendor
│   │   │   └───custom
│   │   │       ├───forms
│   │   │       └───helper
│   │   ├───images
│   │   │   ├───avatar
│   │   │   ├───client
│   │   │   ├───courses
│   │   │   │   └───4by3
│   │   │   ├───element
│   │   │   └───flags
│   │   ├───js
│   │   └───vendor
│   │       ├───bootstrap
│   │       │   ├───dist
│   │       │   │   └───js
│   │       │   ├───js
│   │       │   │   └───src
│   │       │   │       ├───dom
│   │       │   │       └───util
│   │       │   ├───node_modules
│   │       │   │   └───@popperjs
│   │       │   │       └───core
│   │       │   │           └───lib
│   │       │   │               ├───dom-utils
│   │       │   │               ├───modifiers
│   │       │   │               └───utils
│   │       │   └───scss
│   │       │       ├───forms
│   │       │       ├───helpers
│   │       │       ├───mixins
│   │       │       ├───utilities
│   │       │       └───vendor
│   │       ├───bootstrap-icons
│   │       │   └───fonts
│   │       ├───font-awesome
│   │       │   ├───css
│   │       │   └───webfonts
│   │       ├───glightbox
│   │       │   ├───css
│   │       │   └───js
│   │       ├───purecounterjs
│   │       │   └───dist
│   │       └───tiny-slider
│   └───Old Assets
│       └───assets
│           ├───css
│           ├───images
│           │   ├───about
│           │   ├───course-images
│           │   ├───courses
│           │   ├───dashboard
│           │   └───left-imgs
│           ├───js
│           └───vendor
│               ├───bootstrap
│               │   ├───css
│               │   │   └───dist
│               │   │       └───css
│               │   └───js
│               ├───fontawesome-free
│               │   ├───css
│               │   └───webfonts
│               ├───jquery-ui-1.12.1
│               ├───js
│               │   └───src
│               │       └───tools
│               ├───node_modules
│               │   └───popper.js
│               │       └───dist
│               │           └───esm
│               ├───OwlCarousel
│               │   └───assets
│               ├───scss
│               │   ├───mixins
│               │   ├───utilities
│               │   └───vendor
│               ├───semantic
│               └───unicons-2.0.1
│                   ├───css
│                   └───fonts
├───templates
│   ├───base
│   └───Old Templates
│       ├───admin
│       ├───base
│       ├───course
│       ├───dashboard
│       ├───design
│       ├───howto
│       └───userauths
└───userauths
    ├───migrations
    │   └───__pycache__
    └───__pycache__

all i did was add this line in my base.html head section我所做的只是在我的 base.html 头部分添加这一行

<head>
     ...
     <base href="{% static '/' %}">
</head>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 拒绝应用{filename}中的样式,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型 - Refused to apply style from {filename} because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自 '<url> ' 因为它的 MIME 类型('text/html')不是受支持的样式表 MIME 类型</url> - Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用“ <URL> &#39;,因为它的MIME类型(&#39;text / html&#39;)不是受支持的样式表MIME类型,并且启用了严格的MIME检查 - Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled 拒绝应用样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型 - Refused to apply style because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自“xxx/style.css”的样式,因为它的 MIME 类型(“text/html”)不是受支持的样式表 MIME 类型 - Refused to apply style from 'xxx/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用样式,因为它的 MIME 类型('text/html')不是受支持的样式表类型 - Refused to apply style because its MIME type ('text/html') is not a supported stylesheet type 拒绝应用来自 'http://localhost:3000/css/style.css' 的样式,因为它的 MIME 类型 ('text/html') 不是受支持的样式表 MIME 类型 - Refused to apply style from 'http://localhost:3000/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type 应用 css 样式时出现角度错误:拒绝从“路径”应用样式,因为其 MIME 类型(“文本/html”)不是受支持的样式表 MIME 类型 - Angular error when applying css style: Refused to apply style from 'path' because its MIME type ('text/html') is not a supported stylesheet MIME type 拒绝应用来自 'http://localhost:3000/assets/styles/signup.css' 的样式,因为它的 MIME 类型('text/html')不是受支持的样式表 MIME 类型 - Refused to apply style from 'http://localhost:3000/assets/styles/signup.css' because its MIME type('text/html')is not a supported stylesheet MIME type 拒绝从...应用样式,因为它的 MIME 类型 (&#39;text/html&#39;) 不是受支持的样式表 MIME 类型,并且启用了严格的 MIME 检查 - Refused to apply style from... because its MIME type ('text/html') is not a supported style-sheet MIME type, and strict MIME checking is enabled
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM