Home >Web Front-end >CSS Tutorial >Why Is My Django Application Showing 'Resource Interpreted as Stylesheet but Transferred with MIME Type application/x-css' Errors?
Correcting Style Sheet File Loading Issues in Django
Despite an accurate HTML declaration, "Resource interpreted as Stylesheet but transferred with MIME type application/x-css" errors indicate that CSS stylesheets are not loading properly in a Django application. This can occur when the server misinterprets the file type.
Solution:
To correct this, update the project's settings.py file with the following code:
import mimetypes mimetypes.add_type("text/css", ".css", True)
This code registers the .css extension with the text/css MIME type, instructing the server to interpret these files as stylesheets.
Potential Sources of the Issue:
The issue might originate from:
Verification:
After adding the code snippet, restart your application server (e.g., python manage.py runserver) and refresh the web page. The CSS files should now load correctly.
The above is the detailed content of Why Is My Django Application Showing 'Resource Interpreted as Stylesheet but Transferred with MIME Type application/x-css' Errors?. For more information, please follow other related articles on the PHP Chinese website!