I'm using Django 1.8. I get status 200 for both of my css files but the firefox says:
The stylesheet http://localhost:8000/css/full-width-pics.css was not loaded because its MIME type, "text/html", is not "text/css". localhost:8000
The stylesheet http://localhost:8000/css/mainstyle.css was not loaded because its MIME type, "text/html", is not "text/css". localhost:8000
For whatever reason the files are being served as text/html rather than text/css. This is my html.
<link href="css/full-width-pics.css" rel="stylesheet" type="text/css" />
<link href="css/mainstyle.css" rel="stylesheet" type="text/css" />
This is in a base.html file. I extend base.html it in my index.html file. Before I started using template inheritance and had everything in index.html it worked fine.
I'm on Ubuntu. I checked /etc/mime.types. css is listed with text/css.
This has left me really confused
Year 2020 ANSWER:
if you want any mime content type to auto detect by browser this is the solution.
after many painful failed static attempts this is the dynamic solution.
def fetch(request):
import mimetypes
clientRequestUrl=os.getcwd()+'/servlet'+request.path
try: return HttpResponse(fread(clientRequestUrl), content_type=mimetypes.guess_type(request.path)[0])
except Exception as e: return HttpResponse(str(e)+'===> Error Thrown <br>')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.