Why does DEBUG=False setting make my django Static Files Access fail?

后端 未结 14 1945
忘了有多久
忘了有多久 2020-11-22 05:16

Am building an app using Django as my workhorse. All has been well so far - specified db settings, configured static directories, urls, views etc. But trouble started sneaki

14条回答
  •  故里飘歌
    2020-11-22 05:45

    Support for string view arguments to url() is deprecated and will be removed in Django 1.10

    My solution is just small correction to Conrado solution above.

    from django.conf import settings
    import os
    from django.views.static import serve as staticserve
    
    if settings.DEBUG404:
        urlpatterns += patterns('',
            (r'^static/(?P.*)$', staticserve,
                {'document_root': os.path.join(os.path.dirname(__file__), 'static')} ),
            )
    

提交回复
热议问题