CSS not loading wrong MIME type Django

后端 未结 5 2057
星月不相逢
星月不相逢 2020-12-03 21:59

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.

I get

Resour         


        
5条回答
  •  清歌不尽
    2020-12-03 22:43

    I ran into this issue during development (production was using Nginx and serving from /static_cdn folder without any issues).

    The solution came from the Django docs: https://docs.djangoproject.com/en/3.1/howto/static-files/#serving-static-files-during-development

    from django.conf import settings
    from django.conf.urls.static import static
    
    urlpatterns = [
        # ... the rest of your URLconf goes here ...
    ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    

提交回复
热议问题