My urls.py
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'photo.views.home', name='home'),
# url(r'^photo/', include('photo.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns += patterns('django.views.static',
(r'media/(?P<path>.*)$', 'serve', {'document_root': settings.MEDIA_ROOT}),
)
Settings.py
MEDIA_ROOT = 'E:/photo/media'
MEDIA_URL = '/media'
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/static/admin/'
When i try to access user uploaded images it gives me following error.
Using the URLconf defined in photo.urls, Django tried these URL patterns, in this order:
^admin/doc/
^admin/
media/(?P<path>.*)$
The current URL, images/about-landscapes-nature.jpg, didn't match any of these.
What am i doing wrong? User uploaded images are getting stored in photo\media\images
Following is the directory structure in my Win7
photo
media
photoapp
models.py
settings.py
urls.py
I'm not sure if this'll fix all your problems, but MEDIA_URL
needs a trailing slash, so it should be:
MEDIA_URL = '/media/'