python built in server not loading css

前端 未结 2 420
旧巷少年郎
旧巷少年郎 2020-12-10 17:46

when i runserver the django admin is missing css.The web console says that style sheet was not loaded because its MIME type,\"application/x-css\", is not \"text/css\". Thi

2条回答
  •  Happy的楠姐
    2020-12-10 18:29

    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.

提交回复
热议问题