Skip to content Skip to sidebar Skip to footer

Django: Static Files Not Displayed On Deployment Server

I can not get my site to load the static files correctly. settings.py files in regards static files is as follows: # Static files STATIC_URL = '/static/' STATIC_ROOT = '/var/www/st

Solution 1:

You need to add static url rule in your urls.py in order to tell Django to serve static files when any static url is fetched.

if not settings.DEBUG:
    urlpatterns += [
        url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
        url(r'^static/(?P<path>.*)$', 'django.views.static.serve',
            {'document_root': settings.STATIC_ROOT}),
    ]

Post a Comment for "Django: Static Files Not Displayed On Deployment Server"