python built in server not loading css

淺唱寂寞╮ 提交于 2019-11-29 11:41:11

I just ran into the same problem. And it seems you are right about Dreamweaver. Adding above mentioned strings into settings.py didn't helped me.

I have run search for .css at regedit and changed most suspicious registry keys/records which

  1. could be related to treating .css files as application/x-css type
  2. could be related to associating .css file extension to opening with applications, especially Dreamweaver.

It took me two iterations and I can not say for sure which one was the right shot as it might needed some time to update some cache, etc.

Though I changed it at two locations:

  1. HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.css
  2. HKEY_CLASSES_ROOT\.css

I renamed (by adding leading '--' so that it could be recovered if necessary) keys/records related to .css files association with all applications (including Dreamweaver, Notepad, etc.) and stating .css files as application/x-css type.

After that the issue was resolved and Django CSS styles were correctly applied as it was expected.

A little late answer but this needs to be put here for completeness.

I also got this strange error on one development system (I didn't get it on other development systems for the same project). Maybe it is related to the fact that Dreamweaver (which can open css files) was installed on this system?

In any case, to resolve the issue I added the following in my settings.py:

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

This will add (and replace if already exists) the correct mimetype for css in your mimetypes list.

In case you don't want to put it in your settings.py, add it to the __init__.py file of yout settings package.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!