I'm preparing to deploy my Django app and I noticed that when I change the "DEBUG" setting to False, all references to static files (i.e., JavaScript, CSS, etc..) result in HTTP 500 errors.
Any idea what's causing that issue (and how to fix it)?
I'm preparing to deploy my Django app and I noticed that when I change the "DEBUG" setting to False, all references to static files (i.e., JavaScript, CSS, etc..) result in HTTP 500 errors.
Any idea what's causing that issue (and how to fix it)?
I would highly recommend letting your web server handle the static requests, without getting to Django. In my urls.py
, I only add the static request handler when debug is set to True.
Technically, Django serving the static works fine though. Definitely read the short docs page, http://docs.djangoproject.com/en/dev/howto/static-files/. You'll want to use an entry like this in urls.py
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': '/path/to/media'})
It sounds like you might be trying to serve your static media using the Django development server. Take a look at http://docs.djangoproject.com/en/dev/howto/deployment/ for some deployment scenarios/howtos and http://docs.djangoproject.com/en/dev/howto/static-files/ for how to serve static files (but note the disclaimer about NOT using those methods in production).
In general, I'd look at your server logs and see where it's trying to fetch the files from. I suspect the 500 errors are really 404 errors, but they become 500 errors because Django can't find or render the 404.html template. If that's not the case, it would be helpful if you could post the specific 500 error you're getting.