2👍
✅
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': settings.**STATIC_ROOT**, 'show_indexes': True })
I think there Should be MEDIA_ROOT mine in settings.py is like '/home/x/Work/Project/app/static/images/'
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
0👍
Try do next one:
settings.py
STATIC_URL = '/static/'
INSTALLED_APPS += (
'django.contrib.staticfiles',
)
STATIC_ROOT = "/static/"
MEDIA_ROOT = "/media/"
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
STATICFILES_DIRS = (
"/srv/glue/www/static",
)
Add to urls.py
from django.conf.urls import patterns, include, url
from django.conf import settings
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
if settings.DEBUG:
urlpatterns += patterns('django.contrib.staticfiles.views',
url(r'^/(?P<path>.*)$', 'serve'),
)
urlpatterns += staticfiles_urlpatterns()
Source:stackexchange.com