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.
. 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. Please how do i go about fixing this error.
index.html
JavaScript
x
23
23
1
{% load static %}
2
<!DOCTYPE html>
3
<html lang="en">
4
5
<head>
6
<!-- Favicon -->
7
<link rel="shortcut icon" href="{% static 'assets/images/favicon.ico' %}">
8
9
<!-- Google Font -->
10
<link rel="preconnect" href="https://fonts.googleapis.com">
11
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
12
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;700&family=Roboto:wght@400;500;700&display=swap">
13
14
<!-- Plugins CSS -->
15
<link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/font-awesome/css/all.min.css' %}">
16
<link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/bootstrap-icons/bootstrap-icons.css' %}">
17
<link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/tiny-slider/tiny-slider.css' %}">
18
<link rel="stylesheet" type="text/css" href="{% static 'assets/vendor/glightbox/css/glightbox.css' %}">
19
20
<!-- Theme CSS -->
21
<link id="style-switch" rel="stylesheet" type="text/css" href="{% static '/assets/css/style.css' %}">
22
</head>
23
tree
JavaScript
1
116
116
1
├───base
2
│ ├───migrations
3
│ │ └───__pycache__
4
│ └───__pycache__
5
├───course
6
│ ├───migrations
7
│ │ └───__pycache__
8
│ ├───templatetags
9
│ │ └───__pycache__
10
│ └───__pycache__
11
├───dashboard
12
│ ├───migrations
13
│ │ └───__pycache__
14
│ └───__pycache__
15
├───dexxaedprj
16
│ └───__pycache__
17
├───static
18
│ ├───assets
19
│ │ ├───css
20
│ │ │ ├───components
21
│ │ │ │ └───vendor
22
│ │ │ └───custom
23
│ │ │ ├───forms
24
│ │ │ └───helper
25
│ │ ├───images
26
│ │ │ ├───avatar
27
│ │ │ ├───client
28
│ │ │ ├───courses
29
│ │ │ │ └───4by3
30
│ │ │ ├───element
31
│ │ │ └───flags
32
│ │ ├───js
33
│ │ └───vendor
34
│ │ ├───bootstrap
35
│ │ │ ├───dist
36
│ │ │ │ └───js
37
│ │ │ ├───js
38
│ │ │ │ └───src
39
│ │ │ │ ├───dom
40
│ │ │ │ └───util
41
│ │ │ ├───node_modules
42
│ │ │ │ └───@popperjs
43
│ │ │ │ └───core
44
│ │ │ │ └───lib
45
│ │ │ │ ├───dom-utils
46
│ │ │ │ ├───modifiers
47
│ │ │ │ └───utils
48
│ │ │ └───scss
49
│ │ │ ├───forms
50
│ │ │ ├───helpers
51
│ │ │ ├───mixins
52
│ │ │ ├───utilities
53
│ │ │ └───vendor
54
│ │ ├───bootstrap-icons
55
│ │ │ └───fonts
56
│ │ ├───font-awesome
57
│ │ │ ├───css
58
│ │ │ └───webfonts
59
│ │ ├───glightbox
60
│ │ │ ├───css
61
│ │ │ └───js
62
│ │ ├───purecounterjs
63
│ │ │ └───dist
64
│ │ └───tiny-slider
65
│ └───Old Assets
66
│ └───assets
67
│ ├───css
68
│ ├───images
69
│ │ ├───about
70
│ │ ├───course-images
71
│ │ ├───courses
72
│ │ ├───dashboard
73
│ │ └───left-imgs
74
│ ├───js
75
│ └───vendor
76
│ ├───bootstrap
77
│ │ ├───css
78
│ │ │ └───dist
79
│ │ │ └───css
80
│ │ └───js
81
│ ├───fontawesome-free
82
│ │ ├───css
83
│ │ └───webfonts
84
│ ├───jquery-ui-1.12.1
85
│ ├───js
86
│ │ └───src
87
│ │ └───tools
88
│ ├───node_modules
89
│ │ └───popper.js
90
│ │ └───dist
91
│ │ └───esm
92
│ ├───OwlCarousel
93
│ │ └───assets
94
│ ├───scss
95
│ │ ├───mixins
96
│ │ ├───utilities
97
│ │ └───vendor
98
│ ├───semantic
99
│ └───unicons-2.0.1
100
│ ├───css
101
│ └───fonts
102
├───templates
103
│ ├───base
104
│ └───Old Templates
105
│ ├───admin
106
│ ├───base
107
│ ├───course
108
│ ├───dashboard
109
│ ├───design
110
│ ├───howto
111
│ └───userauths
112
└───userauths
113
├───migrations
114
│ └───__pycache__
115
└───__pycache__
116
Advertisement
Answer
all i did was add this line in my base.html head section
JavaScript
1
5
1
<head>
2
3
<base href="{% static '/' %}">
4
</head>
5