Why does Django generate HTTP 500 errors for static media when the Debug option is set to False?

I am ready to deploy my Django application, and I noticed that when I change the "DEBUG" parameter to False, all links to static files (like JavaScript, CSS, etc.) lead to errors HTTP 500.

Any idea what causes this problem (and how to fix it)?

+5
source share
4 answers

I would highly recommend that your web server handle static requests before reaching Django. In mine, urls.pyI only add a static request handler if the debug parameter is set to True.

Technically, Django serving static work works fine. Definitely read the short docs page, http://docs.djangoproject.com/en/dev/howto/static-files/ . You will want to use this entry inurls.py

(r'^static/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': '/path/to/media'})
+12
source

, Django. http://docs.djangoproject.com/en/dev/howto/deployment/ /howtos http://docs.djangoproject.com/en/dev/howto/static-files/ , ( ).

, , . , 500 - 404 , 500 , Django 404.html. , , 500, .

+6

URL- . DEBUG False, URL- "/" , , DEBUG = True, Django "/" , . , , , . .

0

, SECRET_KEY. . .

0

All Articles