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

后端 未结 14 1906
忘了有多久
忘了有多久 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

    If you are using the static serve view in development, you have to have DEBUG = True :

    Warning

    This will only work if DEBUG is True.

    That's because this view is grossly inefficient and probably insecure. This is only intended for local development, and should never be used in production.

    Docs: serving static files in developent

    EDIT: You could add some urls just to test your 404 and 500 templates, just use the generic view direct_to_template in your urls.

    from django.views.generic.simple import direct_to_template
    
    urlpatterns = patterns('',
        ('^404testing/$', direct_to_template, {'template': '404.html'})
    )
    

提交回复
热议问题