why my django admin site does not have the css style

后端 未结 19 1962
南笙
南笙 2020-12-02 07:49

I make a Django admin site using Django development version

But it does not have a CSS style :

\"alt

19条回答
  •  日久生厌
    2020-12-02 08:22

    While following the Django tutorial, I had a similar problem and in my case the issue was the mimetype used by the development server when serving css files.

    The mimetype served was 'application/x-css' which led to following warning message in Chrome (in the 'Network' tab of the Developer tools):

    Resource interpreted as Stylesheet but transferred with MIME type application/x-css: "http://127.0.0.1:8000/static/admin/css/base.css"

    The workaround that I've found: changing the mimetype to be served by adding following lines to the django webapp's manage.py file:

    import mimetypes
    mimetypes.init()
    mimetypes.types_map['.css'] = 'text/css'
    

    Note: worked for me with Django 1.7.4 on Python 2.7 and Chrome 40.0

提交回复
热议问题