Sunday, August 30, 2015

Django debug toolbar causes loss of static files

When setting DEBUG = False in settings.py:

DEBUG = False

Failed to load resource: the server responded with a status of 404

Solution:

In settings.py:

STATIC_ROOT = "/var/www/html/django/MYCOMP/static/"

In urls.py:

urlpatterns += patterns('',
    url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT, }),
)

No comments: