CSS not loading wrong MIME type Django
Adding following snippet into settings.py
file may fix your problem:
import mimetypes
mimetypes.add_type("text/css", ".css", True)
Getting Mime Type Error when loading Django CSS
It's supposed to be text/css
mimetype, like: <link rel="stylesheet" type="text/css" href="mystyle.css">
Django: Refused to apply style from ... because its MIME type ('text/html') is not a supported stylesheet MIME type
all i did was add this line in my base.html head section
<head>
...
<base href="{% static '/' %}">
</head>
Django CSS/JS MIME type (“text/html”) mismatch Error
check your static files settings in settings.py
:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'templates/static'),
]
and add this in master urls.py
:
from django.conf.urls.static import static
if settings.DEBUG:
urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
CSS not working in Django admin: The resource from [css file url] was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff
I got the error
Refused to apply style from '' because its MIME type
('text/html') is not a supported stylesheet MIME type, and strict MIME
checking is enabled.
because one of my Cloudflare manually created firewall rules blocked CSS URLs.
I discovered this when opened my Cloudflare dashboard and sow that firewall rule was applying 'JS challenge' to the URLs like https://[my-website]/static/admin/css/
.
So if your website can not load some resources and you get the error about MIME type
please check your Cloudflare dashboard or try to temporary disable it.
Related Topics
How to Modify Lines in a File In-Place
When Using Os.Execlp, Why 'Python' Needs 'Python' as Argv[0]
Opening a Python Thread in a New Console Window
A Way to "Listen" for Changes to a File System from Python on Linux
Run a Process to /Dev/Null in Python
Package Libffi Was Not Found in the Pkg-Config Search Path Redhat6.5
Why File Read Is Faster on Reading Again
Reading from Linux Command Line with Python
Comparing a String to Multiple Items in Python
Oserror 38 [Errno 38] with Multiprocessing
Oserror: [Error 1] Operation Not Permitted
Pip Error:'Module' Object Has No Attribute 'Cryptography_Has_Ssl_St'
Subprocess.Popen(): Oserror: [Errno 8] Exec Format Error in Python
Typeerror: Argument 1 Must Be Pygame.Surface, Not Str How to Fix
Install Python3-Venv Module on Linux Mint
Python Multiprocessing - Debugging Oserror: [Errno 12] Cannot Allocate Memory