Django template can't see CSS files

前端 未结 5 668
北恋
北恋 2021-01-30 09:25

I\'m building a django app and I can\'t get the templates to see the CSS files... My settings.py file looks like:

MEDIA_ROOT = os.path.join(os.path.abspath(os.p         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 10:03

    On the dev server, I like to cheat and put the following in my urls.py

    if settings.DEBUG:
        urlpatterns += patterns('',
            (r'^includes/(?P.*)$', 'django.views.static.serve', {'document_root': '/path/to/static/files'}),
        )
    

    That way anything in the project under the "/includes" folder is server by the dev server. You could just change that to "/media".

提交回复
热议问题