Django使用js,css等静态文件的时候,出现mime类型问题

使用adminLTE模板, return render(request, 'AdminLTE/index.html') 的时候报如下错误且页面渲染异常,css没有效果:

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8000/host/index/plugins/iCheck/flat/blue.css".

报错截图:

原因:

问题解决了,其实就是js文件没找到,那个200 564是骗人的,html文件里面路径写错了。参考了https://segmentfault.com/q/1010000000652054

处理方法

把dist、plugins,等报错中的静态文件夹包拷贝到static目录

在settings.py中配置

STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'static'),
)

然后修改index.html中静态文件的相对路径,如dist和plugins等

and

and

 

posted @ 2017-09-09 08:53  番茄土豆西红柿  阅读(1893)  评论(0编辑  收藏  举报
TOP