CSS无法加载错误的MIME类型Django [英] CSS not loading wrong MIME type Django

查看:106
本文介绍了CSS无法加载错误的MIME类型Django的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在本地主机中安装了virtualenv,以运行1.8版本的django应用程序,但是在运行时,css和js文件无法加载.

I have installed virtualenv in my localhost to run a django app with 1.8 version but when running it the css and js files doesn't load.

我知道

Resource interpreted as Stylesheet but transferred with MIME type application/x-css

我尝试了一些选项,但它们也不能解决问题.我在其他PC上运行相同的配置,并且可以正常工作.

I have tried some options but they don't solve the issue either. I am running the same configuration on other PC and it works.

我的HTML使用加载CSS:

My HTML loads the css with :

<link href="/static/css/bootstrap.css" rel="stylesheet" type="text/css">

推荐答案

settings.py文件中添加以下代码段可能会解决您的问题:

Adding following snippet into settings.py file may fix your problem:

import mimetypes
mimetypes.add_type("text/css", ".css", True)

来源:服务器中内置的Python无法加载CSS .

这篇关于CSS无法加载错误的MIME类型Django的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆